2023-05-28 23:13:24 +02:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { AES, RC4, Rabbit, TripleDES, enc } from 'crypto-js';
|
|
|
|
|
|
|
|
const algos = { AES, TripleDES, Rabbit, RC4 };
|
|
|
|
|
|
|
|
const cypherInput = ref('Lorem ipsum dolor sit amet');
|
|
|
|
const cypherAlgo = ref<keyof typeof algos>('AES');
|
|
|
|
const cypherSecret = ref('my secret key');
|
|
|
|
const cypherOutput = computed(() => algos[cypherAlgo.value].encrypt(cypherInput.value, cypherSecret.value).toString());
|
|
|
|
|
|
|
|
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),
|
|
|
|
);
|
|
|
|
</script>
|
|
|
|
|
2022-04-07 22:13:09 +02:00
|
|
|
<template>
|
2023-04-20 20:49:28 +02:00
|
|
|
<c-card title="Encrypt">
|
2023-05-27 17:36:15 +02:00
|
|
|
<div flex gap-3>
|
2023-06-25 15:00:50 +02:00
|
|
|
<c-input-text
|
|
|
|
v-model:value="cypherInput"
|
|
|
|
label="Your text:"
|
|
|
|
placeholder="The string to cypher"
|
|
|
|
rows="4"
|
|
|
|
multiline raw-text monospace autosize flex-1
|
|
|
|
/>
|
2023-05-27 17:36:15 +02:00
|
|
|
<div flex flex-1 flex-col gap-2>
|
2023-05-14 21:26:18 +02:00
|
|
|
<c-input-text v-model:value="cypherSecret" label="Your secret key:" clearable raw-text />
|
|
|
|
|
2022-04-24 23:09:12 +02:00
|
|
|
<n-form-item label="Encryption algorithm:" :show-feedback="false">
|
|
|
|
<n-select
|
|
|
|
v-model:value="cypherAlgo"
|
|
|
|
:options="Object.keys(algos).map((label) => ({ label, value: label }))"
|
2022-04-15 23:10:47 +02:00
|
|
|
/>
|
|
|
|
</n-form-item>
|
2023-05-27 17:36:15 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-06-25 15:00:50 +02:00
|
|
|
<c-input-text
|
|
|
|
label="Your text encrypted:"
|
|
|
|
:value="cypherOutput"
|
|
|
|
rows="3"
|
|
|
|
placeholder="Your string hash"
|
|
|
|
multiline monospace readonly autosize mt-5
|
|
|
|
/>
|
2023-04-20 20:49:28 +02:00
|
|
|
</c-card>
|
|
|
|
<c-card title="Decrypt">
|
2023-05-27 17:36:15 +02:00
|
|
|
<div flex gap-3>
|
2023-06-25 15:00:50 +02:00
|
|
|
<c-input-text
|
|
|
|
v-model:value="decryptInput"
|
|
|
|
label="Your encrypted text:"
|
|
|
|
placeholder="The string to cypher"
|
|
|
|
rows="4"
|
|
|
|
multiline raw-text monospace autosize flex-1
|
|
|
|
/>
|
2023-05-27 17:36:15 +02:00
|
|
|
<div flex flex-1 flex-col gap-2>
|
2023-05-14 21:26:18 +02:00
|
|
|
<c-input-text v-model:value="decryptSecret" label="Your secret key:" clearable raw-text />
|
|
|
|
|
2022-04-24 23:09:12 +02:00
|
|
|
<n-form-item label="Encryption algorithm:" :show-feedback="false">
|
|
|
|
<n-select
|
|
|
|
v-model:value="decryptAlgo"
|
|
|
|
:options="Object.keys(algos).map((label) => ({ label, value: label }))"
|
|
|
|
/>
|
|
|
|
</n-form-item>
|
2023-05-27 17:36:15 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-06-25 15:00:50 +02:00
|
|
|
<c-input-text
|
|
|
|
label="Your decrypted text:"
|
|
|
|
:value="decryptOutput"
|
|
|
|
placeholder="Your string hash"
|
|
|
|
rows="3"
|
|
|
|
multiline monospace readonly autosize mt-5
|
|
|
|
/>
|
2023-04-20 20:49:28 +02:00
|
|
|
</c-card>
|
2022-04-07 22:13:09 +02:00
|
|
|
</template>
|