From 9f92fc47cb9a0559974c85063eb4bde37b85a200 Mon Sep 17 00:00:00 2001 From: Apcallover <1503963513@qq.com> Date: Mon, 24 Nov 2025 14:33:23 +0800 Subject: [PATCH] =?UTF-8?q?flat:=20=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 1 + common/globalFunction.js | 7 +- index.html | 13 +- lib/encryption/sm2.min.js | 7 + {static/js => lib/encryption}/sm4.min.js | 0 static/js/aes.js | 234 ----------------------- utils/request.js | 5 +- 7 files changed, 16 insertions(+), 251 deletions(-) create mode 100644 lib/encryption/sm2.min.js rename {static/js => lib/encryption}/sm4.min.js (100%) delete mode 100644 static/js/aes.js diff --git a/App.vue b/App.vue index 3023406..9a66f58 100644 --- a/App.vue +++ b/App.vue @@ -51,6 +51,7 @@ function getUserInfo() { const sm2_privateKey = config.appInfo.sm2PrivateKey; let sm2_encrypt_result = data.data; let sm2_decrypt_result = sm2_Decrypt(sm2_encrypt_result, sm2_privateKey); + console.log(sm2_decrypt_result); if (typeof sm2_decrypt_result == 'string') sm2_decrypt_result = JSON.parse(sm2_decrypt_result); // 其次,对sm2解密后的结果进行 aes解密 diff --git a/common/globalFunction.js b/common/globalFunction.js index e67a461..a4bf4bd 100644 --- a/common/globalFunction.js +++ b/common/globalFunction.js @@ -1,3 +1,4 @@ +import '@/lib/encryption/sm4.min.js' import useUserStore from "../stores/useUserStore"; import { createRequest, @@ -7,9 +8,6 @@ import streamRequest, { chatRequest } from "../utils/streamRequest.js"; -const sm4 = typeof window.sm4 !== 'undefined' ? window.sm4 : - (typeof window.smCrypto !== 'undefined' ? window.smCrypto.sm4 : null); - export const CloneDeep = (props) => { if (typeof props !== 'object' || props === null) { return props @@ -564,7 +562,6 @@ function aes_Decrypt(word, key) { }) return decrypt.toString(CryptoJS.enc.Utf8) } - export function sm2_Decrypt(word, key) { return SM.decrypt(word, key); } @@ -588,7 +585,7 @@ export function sm4Decrypt(key, value, mode = "hex") { return decrypted } catch (e) { - console.log('解密失败') + console.log('解密失败', e) } } diff --git a/index.html b/index.html index 64927f6..2e04e64 100644 --- a/index.html +++ b/index.html @@ -24,16 +24,11 @@ - - - + - - - - -
- + + +