fix(encryption): Alert decryption error (#652)
This commit is contained in:
parent
5e455ba0e9
commit
00d2eea90d
@ -11,9 +11,18 @@ const cypherOutput = computed(() => algos[cypherAlgo.value].encrypt(cypherInput.
|
|||||||
const decryptInput = ref('U2FsdGVkX1/EC3+6P5dbbkZ3e1kQ5o2yzuU0NHTjmrKnLBEwreV489Kr0DIB+uBs');
|
const decryptInput = ref('U2FsdGVkX1/EC3+6P5dbbkZ3e1kQ5o2yzuU0NHTjmrKnLBEwreV489Kr0DIB+uBs');
|
||||||
const decryptAlgo = ref<keyof typeof algos>('AES');
|
const decryptAlgo = ref<keyof typeof algos>('AES');
|
||||||
const decryptSecret = ref('my secret key');
|
const decryptSecret = ref('my secret key');
|
||||||
const decryptOutput = computed(() =>
|
const decryptError = ref<Error | null>(null);
|
||||||
algos[decryptAlgo.value].decrypt(decryptInput.value, decryptSecret.value).toString(enc.Utf8),
|
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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -63,7 +72,11 @@ const decryptOutput = computed(() =>
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<c-alert v-if="decryptError" type="error" mt-5>
|
||||||
|
{{ decryptError }}
|
||||||
|
</c-alert>
|
||||||
<c-input-text
|
<c-input-text
|
||||||
|
v-else
|
||||||
label="Your decrypted text:"
|
label="Your decrypted text:"
|
||||||
:value="decryptOutput"
|
:value="decryptOutput"
|
||||||
placeholder="Your string hash"
|
placeholder="Your string hash"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user