i want to encrypt some data through AES Algorithm. For iOS i'm using AESCrypt Library and for Android i'm using Cipher Library but i am not the same result although it's the same algorithm we're talking about here. Any Help would be appreciated
iOS Code :
NSString *encryptedData = [AESCrypt encrypt:message password:password];
Java Code
public static String encryptMethod(String seedBase64, byte[] key) {
try {
byte[] seed = Base64.decode(seedBase64, 0);
SecretKeySpec keySpec = new SecretKeySpec(key, "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/NoPadding");
cipher.init(1, keySpec);
return Base64.encodeToString(cipher.doFinal(seed), 0);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
Sometimes there are issues with the padding on different platforms so the result differs, i would recommend using some cross platform library like this one. https://github.com/Pakhee/Cross-platform-AES-encryption
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.