代码语言:javascript复制
<script type="text/javascript" src="./crypto-js.js"></script>
<script type="text/javascript">
var password = 'password' // 待加密字段
var secretKey = 'fizz' // key
console.log(`待加密字段: ${password}`)
var aestext = CryptoJS.AES.encrypt(password,secretKey)
console.log(`使用AES加密字段后: ${aestext}`)
var deaecText = CryptoJS.AES.decrypt(aestext.toString(),secretKey).toString(CryptoJS.enc.Utf8)
console.log(`解密AES加密后的字段: ${deaecText}`)
</script>