This commit is contained in:
iLay 2024-12-06 22:06:21 +08:00
parent 694dff0df2
commit ba12f72d1d
2 changed files with 6 additions and 8 deletions

View File

@ -198,7 +198,6 @@ onMounted(() => {
} }
}) })
watch()
</script> </script>
<style scoped> <style scoped>

View File

@ -1,15 +1,14 @@
import { md5 } from "js-md5"; import { md5 } from "js-md5";
import pkg from "crypto-js"; import CryptoJS from "crypto-js";
const crypto = pkg;
const decrypt = function (ciphertext: string, iv: string, t: number): string { const decrypt = function (ciphertext: string, iv: string, t: number): string {
try { try {
const key = generateKey(t); const key = generateKey(t);
const decrypted = crypto.AES.decrypt(ciphertext, crypto.enc.Utf8.parse(key), { const decrypted = CryptoJS.AES.decrypt(ciphertext, CryptoJS.enc.Utf8.parse(key), {
iv: crypto.enc.Hex.parse(iv), iv: CryptoJS.enc.Hex.parse(iv),
mode: crypto.mode.CBC, mode: CryptoJS.mode.CBC,
padding: crypto.pad.Pkcs7 padding: CryptoJS.pad.Pkcs7
}); });
const dec = crypto.enc.Utf8.stringify(decrypted).toString(); const dec = CryptoJS.enc.Utf8.stringify(decrypted).toString();
return dec; return dec;
} catch (error) { } catch (error) {
console.error("Decryption failed", error); console.error("Decryption failed", error);