|
@@ -8,6 +8,8 @@ import { userApi } from '@/api/user';
|
|
|
import { TheArchival } from "@/components"
|
|
|
import CryptoJS from 'crypto-js';
|
|
|
|
|
|
+const SECRET_KEY = 'qwertasdfg159753'
|
|
|
+
|
|
|
const router = useRouter();
|
|
|
const userStore = useUserStore();
|
|
|
|
|
@@ -31,7 +33,7 @@ const handleSubmit = async () => {
|
|
|
|
|
|
try {
|
|
|
loading.value = true;
|
|
|
- const { token } = await userApi.postLogin({ username, password, type: 0 });
|
|
|
+ const { token } = await userApi.postLogin({ username, password: AES_ECB_ENCRYPT(password), type: 0 });
|
|
|
userStore.setUserInfo({ token });
|
|
|
const { user } = await userApi.getUserInfo();
|
|
|
errorMsg.value = '';
|
|
@@ -45,47 +47,27 @@ const handleSubmit = async () => {
|
|
|
loading.value = false;
|
|
|
}
|
|
|
}
|
|
|
-function AES_ECB_DECRYPT(textBase64, secretKey) {
|
|
|
- var keyHex = CryptoJS.enc.Base64.parse(secretKey);
|
|
|
- var decrypt = CryptoJS.AES.decrypt(textBase64, keyHex, {
|
|
|
- "mode": CryptoJS.mode.ECB,
|
|
|
- "padding": CryptoJS.pad.Pkcs7
|
|
|
- });
|
|
|
- return CryptoJS.enc.Utf8.stringify(decrypt);
|
|
|
- }
|
|
|
-function AES_ECB_ENCRYPT(text, secretKey) {
|
|
|
- var keyHex = CryptoJS.enc.Base64.parse(secretKey);
|
|
|
- var messageHex = CryptoJS.enc.Utf8.parse(text);
|
|
|
- var encrypted = CryptoJS.AES.encrypt(messageHex, keyHex, {
|
|
|
- "mode": CryptoJS.mode.ECB,
|
|
|
- // "padding": CryptoJS.pad.Pkcs5
|
|
|
- });
|
|
|
- return encrypted.toString();
|
|
|
- }
|
|
|
-
|
|
|
- // NgGqMDDZE1Qcwhd3iafotw==
|
|
|
-
|
|
|
|
|
|
-function decryptData(encryptedData) {
|
|
|
- const bytes = CryptoJS.AES.decrypt(encryptedData, 'qwertasdfg159753');
|
|
|
- return JSON.parse(bytes.toString(CryptoJS.enc.Utf8));
|
|
|
+// 加密
|
|
|
+function AES_ECB_ENCRYPT(text) {
|
|
|
+ var keyHex = CryptoJS.enc.Utf8.parse(SECRET_KEY);
|
|
|
+ var messageHex = CryptoJS.enc.Utf8.parse(text);
|
|
|
+ var encrypted = CryptoJS.AES.encrypt(messageHex, keyHex, {
|
|
|
+ "mode": CryptoJS.mode.ECB
|
|
|
+ });
|
|
|
+ return encrypted.toString();
|
|
|
}
|
|
|
|
|
|
- function encryptData(data) {
|
|
|
- return CryptoJS.AES.encrypt(JSON.stringify(data), 'qwertasdfg159753').toString();
|
|
|
+// 解密
|
|
|
+function AES_ECB_DECRYPT(textBase64) {
|
|
|
+ var keyHex = CryptoJS.enc.Utf8.parse(SECRET_KEY);
|
|
|
+ var decrypt = CryptoJS.AES.decrypt(textBase64, keyHex, {
|
|
|
+ "mode": CryptoJS.mode.ECB,
|
|
|
+ "padding": CryptoJS.pad.Pkcs7
|
|
|
+ });
|
|
|
+ return CryptoJS.enc.Utf8.stringify(decrypt);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-console.log( AES_ECB_DECRYPT('NgGqMDDZE1Qcwhd3iafotw==', 'qwertasdfg159753') );
|
|
|
-
|
|
|
-// const result = encryptData('admin123你好');
|
|
|
-// console.log( AES_ECB_ENCRYPT( 'admin123你好', 'qwertasdfg159753') );
|
|
|
-// console.log( "result", result );
|
|
|
-
|
|
|
-// console.log( decryptData('NgGqMDDZE1Qcwhd3iafotw==') );
|
|
|
-
|
|
|
-// clg
|
|
|
-// console.log( "decryptData", decryptData() );
|
|
|
</script>
|
|
|
|
|
|
<template>
|