Commit cad11cc5 authored by 杨芳博-DEL's avatar 杨芳博-DEL

添加接口加密

parent ceb3e71a
const SM4 = require("gm-crypt").sm4;
export default function(params) {
if (typeof params == "undefined") {
params = null;
}
// 动态生成key
const nowDate = new Date();
const m = dateZero(nowDate.getMonth() + 1);
const d = dateZero(nowDate.getDate());
const key = `Nanyan@s${nowDate.getFullYear()}${m}${d}`;
let sm4Config = {
//配置sm4参数
key, // key
mode: "ecb", // 加密的方式有两种,ecb和cbc两种,cbc的话下面还要加一个iv的参数,ecb不用
cipherType: "text"
};
let sm4 = new SM4(sm4Config);
let encryptData = sm4.encrypt(params);
return encryptData.trim();
}
function dateZero(num) {
return num < 10 ? "0" + num : num;
}
...@@ -70,6 +70,7 @@ ...@@ -70,6 +70,7 @@
</template> </template>
<script> <script>
import encrypt from '@/utils/crypt'
export default { export default {
data() { data() {
return { return {
...@@ -123,7 +124,7 @@ export default { ...@@ -123,7 +124,7 @@ export default {
return false; return false;
} }
const { userName, verificationCode, newPwd } = this.form; const { userName, verificationCode, newPwd } = this.form;
this._reset({ userName, verificationCode, newPwd }); this._reset({ userName, verificationCode, newPwd:encrypt(newPwd) });
}); });
}, },
//校验用户邮箱 //校验用户邮箱
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
<script> <script>
import { title } from "@/settings"; import { title } from "@/settings";
import { downloadFile } from '@/utils/index' import { downloadFile } from '@/utils/index'
import encrypt from '@/utils/crypt'
export default { export default {
data() { data() {
return { return {
...@@ -81,7 +82,7 @@ export default { ...@@ -81,7 +82,7 @@ export default {
}); });
}, },
_login() { _login() {
this.$apis.LOGIN(this.form).then((res) => { this.$apis.LOGIN({...this.form,passWord:encrypt(this.form.passWord)}).then((res) => {
if (res.returnCode === "0000") { if (res.returnCode === "0000") {
this.$store.commit("common/setUserInfo", res.content); this.$store.commit("common/setUserInfo", res.content);
const path = this.$route.query && this.$route.query.redirect || "/home"; const path = this.$route.query && this.$route.query.redirect || "/home";
......
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