21 lines
644 B
JavaScript
21 lines
644 B
JavaScript
|
var CryptoJS = require("crypto-js");
|
||
|
var fHEX = require("crypto-js/format-hex");
|
||
|
|
||
|
var text = CryptoJS.enc.Hex.parse("12345678123456781234567812345678");
|
||
|
var key = CryptoJS.enc.Hex.parse("12345678123456781234567812345678");
|
||
|
|
||
|
|
||
|
function enc(text, key){
|
||
|
var encrypt = CryptoJS.TripleDES.encrypt(text, key, {
|
||
|
mode: CryptoJS.mode.ECB, //CBC模式
|
||
|
// mode: CryptoJS.mode.ECB, //ECB模式
|
||
|
padding: CryptoJS.pad.NoPadding//padding处理
|
||
|
}
|
||
|
);
|
||
|
var encryptData = encrypt.toString(fHEX);//加密完成后,转换成字符串
|
||
|
console.log( encryptData )
|
||
|
return encryptData;
|
||
|
}
|
||
|
|
||
|
enc(text, key)
|