⼩程序:3DES加密解密3DES加密解密
encryptDES.js主要代码如下:
var CryptoJS = CryptoJS || function(u, l) {
... ...
var encrypt = function() {
var secretKey = "1!QAZ2@WSXCDE#3$4RFVBGT%5^6YHNMJU7&8*IK<.LO9(0P";
var ivKey = "12481632";
var encryptByDES = function encryptByDES(message) {
var keyHex = Utf8.parse(secretKey);
var ivHex = Utf8.parse(ivKey);
js代码加密软件var encrypted = pt(message, keyHex, {
iv: ivHex,
mode: de.CBC,
padding: CryptoJS.pad.Pkcs7
});
String();
};
var decryptByDES = function decryptByDES(ciphertext) {
var keyHex = Utf8.parse(secretKey);
var ivHex = Utf8.parse(ivKey);
var decrypted = CryptoJS.TripleDES.decrypt(ciphertext, keyHex, {
iv: ivHex,
mode: de.CBC,
padding: CryptoJS.pad.Pkcs7
});
Utf8);
};
return {
encryptByDES: encryptByDES,
decryptByDES: decryptByDES
};
}();
encryptByDES: ptByDES,
decryptByDES: encrypt.decryptByDES
}
在项⽬中应⽤:
var encrypt = require('../../utils/encryptDES.js');
var params = ptByDES(data);  //3des加密
var result = encrypt.decryptByDES("需要解密的字符串");  //3DES解密

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。