diff --git a/src/tools/encryption/encryption.vue b/src/tools/encryption/encryption.vue index 4a348f85..f4ebf380 100644 --- a/src/tools/encryption/encryption.vue +++ b/src/tools/encryption/encryption.vue @@ -11,9 +11,18 @@ const cypherOutput = computed(() => algos[cypherAlgo.value].encrypt(cypherInput. const decryptInput = ref('U2FsdGVkX1/EC3+6P5dbbkZ3e1kQ5o2yzuU0NHTjmrKnLBEwreV489Kr0DIB+uBs'); const decryptAlgo = ref('AES'); const decryptSecret = ref('my secret key'); -const decryptOutput = computed(() => - algos[decryptAlgo.value].decrypt(decryptInput.value, decryptSecret.value).toString(enc.Utf8), -); +const decryptError = ref(null); +const decryptOutput = ref(''); +watchEffect(() => { + try { + decryptOutput.value = algos[decryptAlgo.value].decrypt(decryptInput.value, decryptSecret.value).toString(enc.Utf8); + decryptError.value = null; + } + catch (e) { + decryptOutput.value = ''; + decryptError.value = e as Error; + } +});