我正在寻找AES256 CBC解密客户端,
nodeJS中的我使用此函数加密:
exports.encrypt = function(txt, cryptkey){
var cipher = crypto.createCipher('aes-256-cbc',cryptkey);
var crypted = cipher.update(txt,'utf8','hex');
crypted += cipher.final('hex');
console.log(crypted);
return crypted;
};
但我似乎无法在任何客户端库中使用它(JSAES.js,SJCL.js,pidcrypt)
我的猜测是它与base64 / hex编码解码,任何指针有什么关系?
答案 0 :(得分:5)
请查看CryptoJS项目:
以下是AES256 CBC加密/解密的示例:
包含:强>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/mode-cfb-min.js"></script>
<强> JS:强>
var passPhrase = "Secret Phassphrase";
var encrypted = CryptoJS.AES.encrypt("Message", passPhrase, { mode: CryptoJS.mode.CFB });
var decrypted = CryptoJS.AES.decrypt(encrypted, passPhrase, { mode: CryptoJS.mode.CFB });
console.log('encrypted', encrypted);
console.log('decrypted', decrypted.toString(CryptoJS.enc.Utf8));
查看演示