HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
1. Feel Free to ask and submit anything on and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.

applications-security: What is Encryption and Decryption?

How to Encrypt and Decrypt the data using "AES" algorithm.

I need a code in java.Please explain With suitable Examples.

Thanking you.

applications x 10
security x 9
Posted On : 2016-07-26 14:06:32.0


Encryption is the process of converting plain text data (plaintext) into something that appears to be random and meaningless (ciphertext). Decryption is the process of converting ciphertext back to plaintext.

The goal of every encryption algorithm is to make it as difficult as possible to decrypt the generated ciphertext without using the key. If a really good encryption algorithm is used, there is no technique significantly better than methodically trying every possible key. For such an algorithm, the longer the key, the more difficult it is to decrypt a piece of ciphertext without possessing the key.
It is difficult to determine the quality of an encryption algorithm. Algorithms that look promising sometimes turn out to be very easy to break, given the proper attack. When selecting an encryption algorithm, it is a good idea to choose one that has been in use for several years and has successfully resisted all attacks.

You can also design your own Encryption and Decryption algorithm, like you just reverse the input string while encrypting it and same process you apply the encrypted data to get the original one.

for example:
suppose password field for user you store in database in encrypted format just to make it secure by other database users just apply the encryption algorithm on user input, suppose user entered the password as ´!@#$%´ while registering on the application, but you store in DB as ´%$#@!´. Now at login time you apply the same while validating the credentials.

Generally in java we use BASE64 Encoding and Decoding. Java 8 now supports BASE64 Encoding and Decoding.You can use the following classes: java.util.Base64, java.util.Base64.Encoder and java.util.Base64.Decoder..

// encode with padding
String encoded = Base64.getEncoder().encodeToString(someByteArray);

// encode without padding
String encoded = Base64.getEncoder().withoutPadding().encodeToString(someByteArray);

// decode a String
byte [] barr = Base64.getDecoder().decode(encoded);

Posted On : 2016-07-27 11:37:07
Satisfied : 0 Yes  1 No
profile Rishi Kumar - Rishi Kumar
Reply This Thread

Post Answer
Please Login First to Post Answer: Login login with facebook -