I am new to android and I am trying to decrypt the data which is encrypted by making use of crypto-js in nodejs.
Nodejs code
const secretKey = "My secret key here";
const cipherText = CryptoJS.AES.encrypt("Hello world", secretKey);
const encryptedData = cipherText.toString();
Android code
public static String encryptData(String data, String key) throws Exception {
SecretKey secretKey = new SecretKeySpec(Base64.decode(key.getBytes(), Base64.NO_PADDING), "AES");
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
byte[] bytes = cipher.doFinal(data.getBytes("UTF-8"));
String encValue = Base64.encodeToString(bytes, Base64.NO_PADDING);
return encValue;
}
But both encrypted data (from nodejs & android) is not same, so please help me what I need to do in android to get same encrypted data as in nodejs code. Thanks in advance.