refactor(liveRoom): 删除未使用的加密相关代码
- 移除了 cryptConfig、generateKey、decrypt 和 decryptData 等未使用的加密相关函数 - 优化了代码结构,提高了代码的可读性和维护性
This commit is contained in:
parent
86198811aa
commit
9334819414
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user