文件预览加解密默认修改

This commit is contained in:
haozq 2025-02-11 11:14:50 +08:00
parent f55e78ae82
commit 8135b9c086
1 changed files with 26 additions and 10 deletions

View File

@ -6,42 +6,58 @@ const cbc_iv = CryptoJS.enc.Utf8.parse('1234567812345678')
* 默认参数需要加密 * 默认参数需要加密
* @type {boolean} * @type {boolean}
*/ */
const jia_mi = true const jia_mi=false;
/** /**
* 默认后台会自动加密 * 默认后台会自动加密
* @type {boolean} * @type {boolean}
*/ */
const jie_mi = true const jie_mi=false;
/** /**
* 加密 * 加密
* @param word * @param word
* @returns {string} * @returns {string}
*/ */
export const encryptCBC = function (word) { export const encryptCBC = function(word) {
if (!jia_mi) { if(!jia_mi){
return word return word;
} }
const srcs = CryptoJS.enc.Utf8.parse(word) const srcs = CryptoJS.enc.Utf8.parse(word)
const encrypted = CryptoJS.AES.encrypt(srcs, cbc_key, { const encrypted = CryptoJS.AES.encrypt(srcs, cbc_key, {
iv: cbc_iv, iv: cbc_iv,
mode: CryptoJS.mode.CBC, mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7, padding: CryptoJS.pad.Pkcs7
}) })
return encrypted.toString() return encrypted.toString()
} }
/** /**
* 解密 * 解密
* @param word * @param word
* @returns {*} * @returns {*}
*/ */
export const decryptCBC = function (word) { export const decryptCBC = function(word) {
if (!jie_mi) { if(!jie_mi){
return word return word;
} }
const encrypted = CryptoJS.AES.decrypt(word, cbc_key, { const encrypted = CryptoJS.AES.decrypt(word, cbc_key, {
iv: cbc_iv, iv: cbc_iv,
mode: CryptoJS.mode.CBC, mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7, padding: CryptoJS.pad.Pkcs7
}) })
return encrypted.toString(CryptoJS.enc.Utf8) 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()
}