commit | author | age | ||
9bcb19 | 1 | import CryptoJS from 'crypto-js' |
I | 2 | /** |
3 | * @word 要加密的内容 | |
4 | * @keyWord String 服务器随机返回的关键字 | |
5 | */ | |
6 | export function aesEncrypt(word, keyWord = 'XwKsGlMcdPMEhR1B') { | |
7 | var key = CryptoJS.enc.Utf8.parse(keyWord) | |
8 | var srcs = CryptoJS.enc.Utf8.parse(word) | |
9 | var encrypted = CryptoJS.AES.encrypt(srcs, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 }) | |
10 | return encrypted.toString() | |
11 | } |