vue2 新增行为验证码

This commit is contained in:
xingyu
2022-08-02 16:29:45 +08:00
parent ffa2850a22
commit 4a92081937
77 changed files with 1500 additions and 457 deletions

View File

@ -0,0 +1,21 @@
import CryptoJS from 'crypto-js'
/**
* @word 要加密的内容
* @keyWord String 服务器随机返回的关键字
*/
export function aesEncrypt(word, keyWord = 'XwKsGlMcdPMEhR1B') {
const key = CryptoJS.enc.Utf8.parse(keyWord)
const secs = CryptoJS.enc.Utf8.parse(word)
const encrypted = CryptoJS.AES.encrypt(secs, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 })
return encrypted.toString()
}
/**
* @word 要解密的内容
* @keyWord String 服务器随机返回的关键字
*/
export function aesDecrypt(word, keyWord = 'XwKsGlMcdPMEhR1B') {
const key = CryptoJS.enc.Utf8.parse(keyWord)
const decrypt = CryptoJS.AES.decrypt(word, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 })
return CryptoJS.enc.Utf8.stringify(decrypt).toString()
}