前言:密码加密有很多种方案,这里不做过多讨论,本篇文章是基于RSA加密实现。
首先在前端工程中需要引入加密js: "jsencrypt": "2.3.1",(注意单独导入可能报错,可以删除整个node_modules,然后重新npm install)
然后在登陆提交表单的地方代码修改如下:
// 引入js
import {JSEncrypt} from 'jsencrypt'
// 提交表单方法
dataFormSubmit () {
this.dataForm.password = this.passwordEncryption(this.dataForm.password + ',' + new Date().getTime())
this.$http({
url: this.$http.adornUrl('/sys/login'),
method: 'post',
data: this.$http.adornData({
'username': this.dataForm.userName,
'password': this.dataForm.password,
'uuid': this.dataForm.uuid,
'captcha': this.dataForm.captcha
})
},
//密码加密方法
passwordEncryption (passwordUser) {
c