加密
- MD5
js
let token = CryptJS.MD5("文本内容").toString();
- AES
js
function AesEncrypt(data,secret_key){
var ECBOptions = {mode: CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7};//密码,文本,偏移量、模式等设置
var AesSecert = CryptoJS.enc.Utf8.parse(secret_key);//加密密钥
var data_enc = CryptoJS.AES.encrypt(data, AesSecert, ECBOptions).toString()//AES加密
return data_enc //返回加密后的数据,格式为字符串
}
- SHA256
js
let token = CryptJS.SHA256("文本内容").toString();
解密
- AES
js
var body = responseBody
var AES_key= "QWERTYUIOPASDFGH" //秘钥
var ECBOptions = {mode: CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7};
var AesSecert = CryptoJS.enc.Utf8.parse(AES_key);
var data_dec = CryptoJS.AES.decrypt(body, AesSecert, ECBOptions)
var data_dec_str = data_dec.toString(CryptoJS.enc.Utf8)
console.log("解密之后的结果:",data_dec_str)