crypto.js
371 Bytes
import CryptoJS from 'crypto-js'
// 一个固定密钥(自己换掉)
const SECRET_KEY = 'dili-tms'
// AES 加密
export function encrypt(data) {
return CryptoJS.AES.encrypt(data, SECRET_KEY).toString()
}
// AES 解密
export function decrypt(cipherText) {
const bytes = CryptoJS.AES.decrypt(cipherText, SECRET_KEY)
return bytes.toString(CryptoJS.enc.Utf8)
}