I encryption string use objective-c, and use node.js decrypton,but it's not work.
this objective-c code:
NSString *planText = @"Hello World";
NSString *secrectKey = [@"key" SHA256];
NSString *token = [planText AES256EncryptWithKey:secrectKey];
It's output : QV44yFoYVNdPVHA21Fzq7g==
AES256EncryptWithKey this method code is here.
this node.js code:
var crypto = require('crypto');
function decode(cryptkey, secretdata) {
var
decipher = crypto.createDecipher('aes-256-cbc', cryptkey),
decoded = decipher.update(secretdata, 'base64', 'utf8');
decoded += decipher.final( 'utf8' );
return decoded;
}
var cryptkey = crypto.createHash('sha256').update('key').digest();
decode(cryptkey,'QV44yFoYVNdPVHA21Fzq7g==');
but node.js code not output 'Hello World'.
Note: The question has substantially changed.
Use Common Crypto from the security framework and a 3rd party Base64 implementation.
Search SO, there are many good answers to similar questions Or just look at the links in the right sidebar =--->.
Write some code and come back when you need help with the code.