Commit d3b7170f authored by 张伯涛's avatar 张伯涛

加密问题区分对象加密和单个字段加密

parent e11e5776
......@@ -10,13 +10,20 @@ const publicKey = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu6EsPHTuCzwyZ7D0/
'wFNKExmeCvn/zr+UIkRPWHwxfJq+/gw/lt+UzBO2NURhCv4pQZy19vdFLLLeMM09\n' +
'ewIDAQAB'
// 对象加密
export function encrypt(data) {
const json = JSON.stringify(data)
const encryptor = new JSEncrypt()
encryptor.setPublicKey(publicKey)
return encryptor.encrypt(json)
}
// 单个字段加密
export function encryptTwo(data) {
const json = data
const encryptor = new JSEncrypt()
encryptor.setPublicKey(publicKey)
return encryptor.encrypt(json)
}
export function decrypt(txt) {
const encryptor = new JSEncrypt()
encryptor.setPrivateKey('')
......
......@@ -369,7 +369,7 @@ export default {
}
}).catch(() => {
this.loading = false
this.verify = false
this.verify = true
if (this.captchaType === 'MATH' || this.captchaType === 'CHAR') {
this.getCode()
}
......
......@@ -22,7 +22,7 @@
<script>
import { changePassword } from '@/api/personalCenter'
import { encrypt } from '@/utils/jsencrypt'
import { encryptTwo } from '@/utils/jsencrypt'
export default {
name: 'ChangePassword',
data() {
......@@ -59,8 +59,8 @@ export default {
if (valid) {
this.loading = true
const params = {
oldPassword: encrypt(this.personalForm.oldPassword),
newPassword: encrypt(this.personalForm.newPasswordTo)
oldPassword: encryptTwo(this.personalForm.oldPassword),
newPassword: encryptTwo(this.personalForm.newPasswordTo)
}
changePassword(params).then(res => {
if (res.code === 200) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment