[JavaScript] 纯文本查看 复制代码 const CryptoJS = require('crypto-js');
function d(t) {
if ("" === t || void 0 == t)
return "";
var e = [];
e.push("0x");
for (var r = 0; r < t.length; r++)
e.push(t.charCodeAt(r).toString(16));
return e.join("")
}
function encrypt(t) {
var u = "11223344556677889900aabbccddeeff"
var e = u,
r = d(t),
i = CryptoJS.enc.Hex.parse(e),
n = CryptoJS.enc.Hex.parse(r),
o = CryptoJS.TripleDES.encrypt(n, i, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
}),
a = o.ciphertext.toString(CryptoJS.enc.Hex);
return a
}
data = '{"tag":"47","mobilePhone":"13812345678"}'
console.log(encrypt(data)) |