赞
踩
yarn add crypto-js
utils.js文件里 封装加密、解密方法
const CryptoJS = require('crypto-js')
const key = CryptoJS.enc.Utf8.parse('xxxx_aes_v1_mweb')
// 解密方法
export function Decrypt(word) {
let decrypt = CryptoJS.AES.decrypt(word, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 })
let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8)
return decryptedStr.toString()
}
// 加密方法
export function Encrypt(word) {
let srcs = CryptoJS.enc.Utf8.parse(word)
let encrypted = CryptoJS.AES.encrypt(srcs, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 })
return encrypted.toString()
}
import { Encrypt, Decrypt } from '@const/utils';
let EData = Encrypt(111111)
console.log('151', EData)
console.log('151', Decrypt(EData))
转自:https://blog.csdn.net/snowball_li/article/details/125423127
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。