|
@@ -6,6 +6,9 @@ import { SvgIcon } from '@/components';
|
|
|
import { useUserStore } from '@/stores/modules/userStore';
|
|
|
import { userApi } from '@/api/user';
|
|
|
import { TheArchival } from "@/components"
|
|
|
+import CryptoJS from 'crypto-js';
|
|
|
+
|
|
|
+const SECRET_KEY = 'qwertasdfg159753'
|
|
|
|
|
|
const router = useRouter();
|
|
|
const userStore = useUserStore();
|
|
@@ -30,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,6 +48,26 @@ const handleSubmit = async () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// 加密
|
|
|
+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 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);
|
|
|
+}
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<template>
|