From 8135b9c0869fde1e17a2f8d56842f2d9715e64f7 Mon Sep 17 00:00:00 2001 From: haozq <1611483981@qq.com> Date: Tue, 11 Feb 2025 11:14:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E9=A2=84=E8=A7=88=E5=8A=A0?= =?UTF-8?q?=E8=A7=A3=E5=AF=86=E9=BB=98=E8=AE=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/aescbc.js | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/utils/aescbc.js b/src/utils/aescbc.js index 3da8d7f..f5ad680 100644 --- a/src/utils/aescbc.js +++ b/src/utils/aescbc.js @@ -6,42 +6,58 @@ const cbc_iv = CryptoJS.enc.Utf8.parse('1234567812345678') * 默认参数需要加密 * @type {boolean} */ -const jia_mi = true +const jia_mi=false; /** * 默认后台会自动加密 * @type {boolean} */ -const jie_mi = true +const jie_mi=false; /** * 加密 * @param word * @returns {string} */ -export const encryptCBC = function (word) { - if (!jia_mi) { - return word +export const encryptCBC = function(word) { + if(!jia_mi){ + return word; } const srcs = CryptoJS.enc.Utf8.parse(word) const encrypted = CryptoJS.AES.encrypt(srcs, cbc_key, { iv: cbc_iv, mode: CryptoJS.mode.CBC, - padding: CryptoJS.pad.Pkcs7, + padding: CryptoJS.pad.Pkcs7 }) return encrypted.toString() } + /** * 解密 * @param word * @returns {*} */ -export const decryptCBC = function (word) { - if (!jie_mi) { - return word +export const decryptCBC = function(word) { + if(!jie_mi){ + return word; } const encrypted = CryptoJS.AES.decrypt(word, cbc_key, { iv: cbc_iv, mode: CryptoJS.mode.CBC, - padding: CryptoJS.pad.Pkcs7, + padding: CryptoJS.pad.Pkcs7 }) return encrypted.toString(CryptoJS.enc.Utf8) } + +/** + * 文件预览专用 + * @param word + * @returns {string} + */ +export const encryptCBCTime= function(word) { + const srcs = CryptoJS.enc.Utf8.parse(word) + const encrypted = CryptoJS.AES.encrypt(srcs, cbc_key, { + iv: cbc_iv, + mode: CryptoJS.mode.CBC, + padding: CryptoJS.pad.Pkcs7 + }) + return encrypted.toString() +}