登录接口参数加密
This commit is contained in:
@@ -80,6 +80,7 @@
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { NsMessage } from '/nerv-lib/component';
|
||||
import { replyDynamRoutesPath } from '/nerv-lib/util/dynamicRoutesss';
|
||||
import { Enobscure, Deobscure } from '/nerv-lib/util/crypto';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'UserLogin',
|
||||
@@ -124,11 +125,9 @@
|
||||
}
|
||||
});
|
||||
const submit = (value): void => {
|
||||
console.log(value);
|
||||
|
||||
let data = JSON.stringify({
|
||||
accountNo: userName.value.trim(),
|
||||
password: password.value.trim(),
|
||||
password: Enobscure(password.value.trim()),
|
||||
});
|
||||
validator(null, value?.code)
|
||||
.then(() => {
|
||||
|
24
lib/util/crypto.ts
Normal file
24
lib/util/crypto.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import * as CryptoJS from 'crypto-js';
|
||||
const key = CryptoJS.enc.Utf8.parse("1234567890123456");
|
||||
const iv = CryptoJS.enc.Utf8.parse("1234567890123456");
|
||||
//加密方法,key:秘钥,iv:id
|
||||
export const Enobscure = (word:any) => {
|
||||
const srcs = CryptoJS.enc.Utf8.parse(word);
|
||||
const encrypted = CryptoJS.AES.encrypt(srcs, key, {
|
||||
iv: iv,
|
||||
mode: CryptoJS.mode.CBC,
|
||||
padding: CryptoJS.pad.Pkcs7,
|
||||
});
|
||||
return CryptoJS.enc.Base64.stringify(encrypted.ciphertext);
|
||||
}
|
||||
//解密方法
|
||||
export const Deobscure = (word:any) => {
|
||||
const base64 = CryptoJS.enc.Base64.parse(word);
|
||||
const src = CryptoJS.enc.Base64.stringify(base64);
|
||||
const decrypt = CryptoJS.AES.decrypt(src, key, {
|
||||
iv: iv,
|
||||
mode: CryptoJS.mode.CBC,
|
||||
padding: CryptoJS.pad.Pkcs7,
|
||||
});
|
||||
return CryptoJS.enc.Utf8.stringify(decrypt);
|
||||
}
|
Reference in New Issue
Block a user