Below is AES encryption method for Android, what would be the equivalent implementation in delphi for iOS.... I tried using lockbox but I don't getthe same encrypted result.

Below is AES encryption method for Android, what would be the equivalent implementation in delphi for iOS.... I tried using lockbox but I don't getthe same encrypted result.

public static String encryptAES(String password, String value) throws GeneralSecurityException, UnsupportedEncodingException {
Rfc2898DeriveBytes keyGenerator = new Rfc2898DeriveBytes(password, salt);
byte[] key = keyGenerator.getBytes(32);
byte[] iv = keyGenerator.getBytes(16);

SecretKeySpec secret = new SecretKeySpec(key, "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding");
cipher.init(Cipher.ENCRYPT_MODE, secret, new IvParameterSpec(iv));
byte[] cipherText = cipher.doFinal(value.getBytes("UTF-16LE"));
return new String(Base64.encodeToString(cipherText, Base64.DEFAULT));
}

Comments

Post a Comment