I struggled for two days to find a cross-platform solution on aes, and now I got it.
Thanks for these people's work!!!
https://github.com/Gurpartap/aescrypt
https://github.com/Gurpartap/AESCrypt-ObjC
https://github.com/scottyab/AESCrypt-Android
The nodejs version is interoperable with the code above.
var aes = require("./aes");
var encrypted = aes.encrypt("helloworld", "123456");
console.log(encrypted);
// oJr7/fYMOVfoHulUu8n3rQ==
var decrypted = aes.decrypt(encrypted, "123456");
console.log(decrypted);
// helloworld
aes-256-cbc
in thecrypto
module defaults usepkcs5
padding, but on iOS, onlypkcs7
is supported.- The initial vector is set up as blank which may be not secure, please know it.
- The key can be any string since we do
sha256
hash on it.
The code on https://github.com/node-webot/wechat-crypto helps a lot.