aes.js
628 Bytes
import CryptoJS from 'crypto-js'
const AES_KEY = '94a80df2633b4944'
export function aesEncode(str) {
const key = CryptoJS.enc.Utf8.parse(AES_KEY)
const word = CryptoJS.enc.Utf8.parse(str)
debugger
const encrypted = CryptoJS.AES.encrypt(word, key, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
})
return encrypted.toString()
}
export function aesDecode(passPhrase) {
const key = CryptoJS.enc.Utf8.parse(AES_KEY)
const decrypt = CryptoJS.AES.decrypt(passPhrase, key, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
})
return CryptoJS.enc.Utf8.stringify(decrypt).toString()
}