node js AES加密

原文 https://blog.csdn.net/s_crawler/article/details/107630473

var CryptoJS = require(“crypto-js”);
var key= CryptoJS.enc.Utf8.parse(“ASDFGH1234567895”),
iv = CryptoJS.enc.Utf8.parse(“0123456789ABCDEF”);

function encrypt(text) {
var a = CryptoJS.AES.encrypt(text, key, {
iv: iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
})
, r = a.toString();
return r
}

function decrypt(text) {
var a = CryptoJS.AES.decrypt(text, key, {
iv: iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
})
, r = a.toString(CryptoJS.enc.Utf8);
return r.toString()
}
function encrypt(text) {
var a = CryptoJS.AES.encrypt(text, key, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
})
, r = a.toString();
return r
}

function decrypt(text) {
var a = CryptoJS.AES.decrypt(text, key, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
})
, r = CryptoJS.enc.Utf8.stringify(a).toString();
return r
}
————————————————
版权声明:本文为CSDN博主「夜月不挂科」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/s_crawler/article/details/107630473

你可能感兴趣的:(js逆向,javascript,前端,开发语言)