1
0
Fork 0
mirror of https://github.com/CorentinTh/it-tools.git synced 2025-07-19 13:19:37 +02:00
it-tools/src/tools/hash-text/hash-text.vue

42 lines
1.1 KiB
Vue
Raw Normal View History

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
<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">
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;
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.',
);
const hashText = (algo: AlgoNames, value: string) => algos[algo](value).toString();
2022-04-04 00:25:53 +02:00
</script>