[java] Cipher

javax.crypto.Cipher

Encrypt

Cipher cipher = Cipher.getInstance( "AES/CBC/PKCS5Padding" );

cipher.init(Cipher.ENCRYPT_MODE, key);

byte [] cipherBytes = cipher.doFinal(plainBytes);

Decrypt

Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");

cipher.init(Cipher.DECRYPT_MODE,key);

byte [] plainBytesDecrypted = cipher.doFinal(cipherBytes);

ref : http://www.pixelstech.net/article/1439554008-Java-Cipher-encryption-decryption-example

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s