Commit d0d98175 authored by xulili's avatar xulili

密码加密

parent f1ac4cb2
......@@ -12,6 +12,7 @@
"dependencies": {
"animate.css": "^4.1.1",
"axios": "^0.18.0",
"crypto-js": "^4.0.0",
"echarts": "^4.2.0-rc.2",
"element-ui": "^2.7.2",
"file-saver": "^2.0.0-rc.3",
......
......@@ -14,6 +14,7 @@
placeholder="请输入用户名"
autofocus
clearable
ininput="value = value.trim()"
>
<i class="icon-username icon-prefix" slot="prefix"> </i>
</el-input>
......@@ -25,6 +26,7 @@
placeholder="请输入密码"
autofocus
clearable
ininput="value = value.trim()"
>
<i class="icon-pwd icon-prefix" slot="prefix"> </i>
</el-input>
......@@ -47,6 +49,7 @@
<script>
import { loginOut } from "@/config/loginOut";
import util from "@/utils/util.js";
export default {
data() {
return {
......@@ -76,7 +79,7 @@ export default {
_this.flag = true;
let requestParams = {};
requestParams.username = _this.form.username;
requestParams.password = _this.form.password;
requestParams.password = util.encrypt(_this.form.password);
let params = this.$qs.stringify(requestParams);
_this
.$https(
......
......@@ -19,6 +19,7 @@
v-model="form.oldPassWord"
placeholder="请输入当前密码"
type="password"
oninput="value = value.trim()"
></el-input>
</el-form-item>
<el-form-item label="请输入新密码" prop="password">
......@@ -26,6 +27,7 @@
v-model="form.password"
placeholder="请输入新密码"
type="password"
oninput="value = value.trim()"
>
</el-input>
</el-form-item>
......@@ -34,6 +36,7 @@
v-model="form.checkPass"
placeholder="请再次输入新密码"
type="password"
oninput="value = value.trim()"
>
</el-input>
</el-form-item>
......@@ -50,6 +53,7 @@
</template>
<script>
import { loginOut } from "@/config/loginOut.js";
import util from "@/utils/util.js";
export default {
data() {
var validatePass = (rule, value, callback) => {
......@@ -78,6 +82,7 @@ export default {
rules: {
oldPassWord: [
{ required: true, message: "请输入原密码", trigger: "blur" },
{ min: 1, max: 20, message: "请输入不大于100位" },
],
password: [
{ required: true, validator: validatePass, trigger: "blur" },
......@@ -96,15 +101,15 @@ export default {
password: "",
checkPass: "",
};
this.$router.go(-1)
this.$router.go(-1);
},
handleSubmit() {
let _this = this;
this.$refs.form.validate((valid) => {
if (valid) {
let requestParams = {};
requestParams.oldPassWord = _this.form.oldPassWord;
requestParams.password = _this.form.password;
requestParams.oldPassWord = util.encrypt(_this.form.oldPassWord);
requestParams.password = util.encrypt(_this.form.password);
_this
.$https(
{
......
const CryptoJS = require('crypto-js')
let util = {};
let key = 'guobomimajiamics'
let cryptKey = CryptoJS.enc.Utf8.parse(key);
// 加密
util.encrypt = function (str) {
if (!str) return null
let srcs = CryptoJS.enc.Utf8.parse(str);
const cryptInfo = CryptoJS.AES.encrypt(srcs, cryptKey, {
iv: cryptKey,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
})
return cryptInfo.toString()
}
export default util
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