|
@@ -6,6 +6,7 @@ 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 router = useRouter();
|
|
|
const userStore = useUserStore();
|
|
@@ -44,7 +45,47 @@ 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 encryptData(data) {
|
|
|
+ return CryptoJS.AES.encrypt(JSON.stringify(data), 'qwertasdfg159753').toString();
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+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>
|