I am doing AES 128 bit encyption and decryption using following java code which works fine. For same key and data it gives me same output each time.
link1: http://aesencryption.net/#Java-aes-encryption-example
(final String strPssword = "dAtAbAsE98765432";)
For AES 256 bit encryption and decryption I found another java code. It gives me different output each time.
link2: AES-256 Password Based Encryption/Decryption in Java
My question is that, whether i need to wirte different code for AES 128 bit and AES 256 bit? Or are they same? only key size is different?
For 256 bit encryption only i need to change in first java code link
public boolean setKey(String sKey){
arbtKey = Arrays.copyOf(arbtKey, 32); // use only first 256 bits
}
public static void main(String[] aryCmdArgs)
{
final String sKey = "dAtAbAsE98765432dAtAbAsE98765432"; //256 bits
}
or i need to use a code given in link2?