2022-04-04 00:25:53 +02:00
|
|
|
<template>
|
2022-04-15 23:10:47 +02:00
|
|
|
<div>
|
|
|
|
<n-card>
|
2022-04-22 23:31:40 +02:00
|
|
|
<n-input v-model:value="clearText" type="textarea" placeholder="Your string..." :autosize="{ minRows: 3 }" />
|
2022-04-04 00:25:53 +02:00
|
|
|
|
2022-05-12 00:29:55 +10:00
|
|
|
<n-divider />
|
|
|
|
|
|
|
|
<div v-for="algo in algoNames" :key="algo" style="margin: 5px 0">
|
|
|
|
<n-input-group>
|
|
|
|
<n-input-group-label style="flex: 0 0 120px"> {{ algo }} </n-input-group-label>
|
|
|
|
<input-copyable :value="hashText(algo, clearText)" readonly />
|
|
|
|
</n-input-group>
|
|
|
|
</div>
|
2022-04-15 23:10:47 +02:00
|
|
|
</n-card>
|
|
|
|
</div>
|
2022-04-04 00:25:53 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2022-05-12 00:29:55 +10:00
|
|
|
import InputCopyable from '../../components/InputCopyable.vue';
|
|
|
|
import { ref } from 'vue';
|
2022-04-22 23:31:40 +02:00
|
|
|
import { MD5, SHA1, SHA256, SHA224, SHA512, SHA384, SHA3, RIPEMD160 } from 'crypto-js';
|
2022-04-04 00:25:53 +02:00
|
|
|
|
|
|
|
const algos = {
|
2022-04-22 23:31:40 +02:00
|
|
|
MD5,
|
|
|
|
SHA1,
|
|
|
|
SHA256,
|
|
|
|
SHA224,
|
|
|
|
SHA512,
|
|
|
|
SHA384,
|
|
|
|
SHA3,
|
|
|
|
RIPEMD160,
|
2022-04-04 00:25:53 +02:00
|
|
|
} as const;
|
|
|
|
|
2022-05-12 00:29:55 +10:00
|
|
|
type AlgoNames = keyof typeof algos;
|
|
|
|
const algoNames = Object.keys(algos) as AlgoNames[];
|
|
|
|
|
2022-04-22 23:31:40 +02:00
|
|
|
const clearText = ref(
|
|
|
|
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lacus metus blandit dolor lacus natoque ad fusce aliquam velit.',
|
|
|
|
);
|
2022-05-12 00:29:55 +10:00
|
|
|
const hashText = (algo: AlgoNames, value: string) => algos[algo](value).toString();
|
2022-04-04 00:25:53 +02:00
|
|
|
</script>
|