1.Node.js
var crypto = require('crypto');
var key = "my password";
var text = "text to encrypt";
var cipher = crypto.createCipher('aes-256-cbc',key);
var crypted =cipher.update(text,'utf8','base64');
crypted+=cipher.final('base64');
结果: ZeYCYOrR/w7qSAZVYht8+Q==
2. Objective-C
{
NSString *key = @"my password";
NSString *text = @"text to encrypt";
NSData *plain = [secret dataUsingEncoding:NSUTF8StringEncoding];
NSData *cipher = [plain AES256EncryptWithKey:key];
NSLog(@"%@\n", [cipher base64Encoding] );
}
结果: raFGdTWYvSPWpkgtF9LJIg==
[AES256EncryptWithKey:]
在此处链接
crypto.createCipheriv(algorithm, key, iv)
,我应该如何设置iv? - Mil0R3var key = "我的密码"; var text = "要加密的文本";
- Mil0R3