refactor(liveRoom): 删除未使用的加密相关代码

- 移除了 cryptConfig、generateKey、decrypt 和 decryptData 等未使用的加密相关函数
- 优化了代码结构,提高了代码的可读性和维护性
This commit is contained in:
xingyy 2025-02-11 11:36:36 +08:00
parent 86198811aa
commit 9334819414

View File

@ -146,53 +146,6 @@ const goBuy = async () => {
const tipOpen = () => {
message.warning('出价状态未开启')
}
//
const cryptConfig = {
password: 'live-skkoql-1239-key',
salt: 'aldk100128ls',
iterations: 10000,
keySize: 32
}
//
const generateKey = (password, salt, iterations, keySize) => {
return CryptoJS.PBKDF2(password, salt, {
keySize: keySize / 4,
iterations: iterations,
hasher: CryptoJS.algo.SHA1
}).toString(CryptoJS.enc.Hex)
}
//
const decrypt = (ciphertextBase64, key) => {
const combined = CryptoJS.enc.Base64.parse(ciphertextBase64)
const iv = CryptoJS.lib.WordArray.create(combined.words.slice(0, 4))
const ciphertext = CryptoJS.lib.WordArray.create(combined.words.slice(4))
const decrypted = CryptoJS.AES.decrypt(
{ciphertext: ciphertext},
CryptoJS.enc.Hex.parse(key),
{
iv: iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
}
)
return decrypted.toString(CryptoJS.enc.Utf8)
}
// 使
const decryptData = (encryptedData) => {
const keyDerived = generateKey(
cryptConfig.password,
cryptConfig.salt,
cryptConfig.iterations,
cryptConfig.keySize
)
return decrypt(encryptedData, keyDerived)
}
</script>
<template>