用户登录密码传输未加密,不太安全 加密方法有js-sha256、aes、des、ras
一、aes.js
安装 npm install js-sha256
var CryptoJS = require('crypto-js')
var key = 'abcdefgabcdefg12'
export function encrypt(text) {
return CryptoJS.AES.encrypt(text, CryptoJS.enc.Utf8.parse(key), {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7,
})
}
export function decrypt(text) {
var result = CryptoJS.AES.decrypt(text, CryptoJS.enc.Utf8.parse(key), {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7,
})
return result.toString(CryptoJS.enc.Utf8)
}
二、具体代码
import { encrypt, decrypt } from '@/assets/js/aes.js'
password:encrypt(this.account.password).toString()
encrypt(this.account.password).toString()
decrypt(accountInfo.password)
三级目录
链接: https://blog.csdn.net/qq_34707272/article/details/121857485. 链接: https://blog.csdn.net/weixin_55560445/article/details/114419955.
|