fullstack.web/swa/token/jssrc/test.js

21 lines
644 B
JavaScript
Raw Normal View History

2023-08-09 05:57:49 +00:00
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)