提交 | 用户 | 时间 | ||
820397 | 1 | import CryptoJS from 'crypto-js' |
H | 2 | /** |
3 | * @word 要加密的内容 | |
4 | * @keyWord String 服务器随机返回的关键字 | |
5 | * */ | |
6 | export function aesEncrypt(word, keyWord = 'XwKsGlMcdPMEhR1B') { | |
7 | const key = CryptoJS.enc.Utf8.parse(keyWord) | |
8 | const srcs = CryptoJS.enc.Utf8.parse(word) | |
9 | const encrypted = CryptoJS.AES.encrypt(srcs, key, { | |
10 | mode: CryptoJS.mode.ECB, | |
11 | padding: CryptoJS.pad.Pkcs7 | |
12 | }) | |
13 | return encrypted.toString() | |
14 | } |