hello,
I am doing AES-128 encryption on some data and storing the encrypted data into MySQL db. But the problem is when I am trying to get the data by MySQL query like -
select AES_DECRYPT(columnName,'0123456789ABCDEF') from tableName;
I am not getting the same data as query output of the encrypted data. I am confused about the problem. My encryption code look like -
public static void main(String[] args) throws Exception {
String message = "Strong Versus Unlimited Strength Cryptography";
SecretKeySpec skeySpec = new SecretKeySpec("0123456789ABCDEF".getBytes(), "AES"); //AES-128
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
byte[] encrypted = cipher.doFinal(message.getBytes());
System.out.println("encrypted string: " + encrypted); //storing into MySQL DB
cipher.init(Cipher.DECRYPT_MODE, skeySpec);
byte[] original = cipher.doFinal(encrypted);
String originalString = new String(original);
System.out.println("Original string: " + originalString);
}
Can some one tell me what I am doing wrong here?