Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

128 bit data encryption using Java

I need to store some sensitive data by encrypting it with atleast 128 bit key. I investigated into javax.crypto package and found that there are certain Cipher names, like PBEWithMD5AndDES or PBEWithSHA1AndDESede which provides encryption upto 56 bit and 80 bit (http://en.wikipedia.org/wiki/DESede).

I referred other guys posts but those are mainly using RSA and in my understanding RSA is generally suitable for encrypting the communication data (with private-public key pair). My need is different, I just want to store the data and retrieve it back by decrypting it. Therefore I don't need any private-public key pairs.

Please let me know if you have any idea about this.

like image 716
jatanp Avatar asked Sep 08 '08 06:09

jatanp


1 Answers

Use Advanced Encryption Standard (AES). It supports Key lengths of 128, 192, or 256 bits.

The algorithm is simple. The Sun Java website has a section explaining how to do AES encryption in Java.

From Wikipedia...

... the Advanced Encryption Standard (AES), also known as Rijndael, is a block cipher adopted as an encryption standard by the U.S. government. It has been analyzed extensively and is now used worldwide, as was the case with its predecessor, the Data Encryption Standard (DES)...

So as a rule of thumb you are not supposed to use DES or its variants because it is being phased out.

As of now, it is better to use AES. There are other options like Twofish, Blowfish etc also. Note that Twofish can be considered as an advanced version of Blowfish.

like image 127
Niyaz Avatar answered Oct 02 '22 23:10

Niyaz