mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-08 07:11:03 -04:00
fix(encryption): Alert decryption error (#652)
This commit is contained in:
parent
5e455ba0e9
commit
00d2eea90d
1 changed files with 16 additions and 3 deletions
|
@ -11,9 +11,18 @@ const cypherOutput = computed(() => algos[cypherAlgo.value].encrypt(cypherInput.
|
|||
const decryptInput = ref('U2FsdGVkX1/EC3+6P5dbbkZ3e1kQ5o2yzuU0NHTjmrKnLBEwreV489Kr0DIB+uBs');
|
||||
const decryptAlgo = ref<keyof typeof algos>('AES');
|
||||
const decryptSecret = ref('my secret key');
|
||||
const decryptOutput = computed(() =>
|
||||
algos[decryptAlgo.value].decrypt(decryptInput.value, decryptSecret.value).toString(enc.Utf8),
|
||||
);
|
||||
const decryptError = ref<Error | null>(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;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -63,7 +72,11 @@ const decryptOutput = computed(() =>
|
|||
/>
|
||||
</div>
|
||||
</div>
|
||||
<c-alert v-if="decryptError" type="error" mt-5>
|
||||
{{ decryptError }}
|
||||
</c-alert>
|
||||
<c-input-text
|
||||
v-else
|
||||
label="Your decrypted text:"
|
||||
:value="decryptOutput"
|
||||
placeholder="Your string hash"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue