aboutsummaryrefslogtreecommitdiff
path: root/src/tools/hash-text/hash-text.vue
diff options
context:
space:
mode:
authorGravatar Corentin Thomasset <corentin.thomasset74@gmail.com> 2022-04-04 00:25:53 +0200
committerGravatar Corentin Thomasset <corentin.thomasset74@gmail.com> 2022-04-04 00:25:53 +0200
commit0f3b7445ad1f945d9b364476147bf824ac309a6c (patch)
treef852e67ad2b7c3d9bb291618eeabe974d21115d5 /src/tools/hash-text/hash-text.vue
parent40dec52c8467fd27eb8f3857ed72746ebaa4f509 (diff)
downloadit-tools-0f3b7445ad1f945d9b364476147bf824ac309a6c.tar.gz
it-tools-0f3b7445ad1f945d9b364476147bf824ac309a6c.tar.zst
it-tools-0f3b7445ad1f945d9b364476147bf824ac309a6c.zip
feat(tool): text hash
Diffstat (limited to 'src/tools/hash-text/hash-text.vue')
-rw-r--r--src/tools/hash-text/hash-text.vue72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/tools/hash-text/hash-text.vue b/src/tools/hash-text/hash-text.vue
new file mode 100644
index 0000000..30a97b8
--- /dev/null
+++ b/src/tools/hash-text/hash-text.vue
@@ -0,0 +1,72 @@
+<template>
+ <div>
+ <n-card>
+ <n-input
+ v-model:value="clearText"
+ type="textarea"
+ placeholder="Your string..."
+ :autosize="{ minRows: 3 }"
+ />
+ <br />
+ <br />
+ <n-select
+ v-model:value="algo"
+ :options="Object.keys(algos).map(label => ({ label, value: label }))"
+ />
+
+ <br />
+ <n-input
+ style="text-align: center;"
+ v-model:value="hashedText"
+ type="textarea"
+ placeholder="Your string hash"
+ :autosize="{ minRows: 1 }"
+ readonly
+ autocomplete="off"
+ autocorrect="off"
+ autocapitalize="off"
+ spellcheck="false"
+ />
+ <br />
+ <br />
+ <n-space justify="center">
+ <n-button @click="copy" secondary autofocus>Copy</n-button>
+ </n-space>
+ </n-card>
+ </div>
+</template>
+
+<script setup lang="ts">
+import { useCopy } from '@/composable/copy';
+import { ref, computed } from 'vue'
+import {
+ MD5,
+ SHA1,
+ SHA256,
+ SHA224,
+ SHA512,
+ SHA384,
+ SHA3,
+ RIPEMD160,
+} from 'crypto-js'
+
+const algos = {
+ MD5,
+ SHA1,
+ SHA256,
+ SHA224,
+ SHA512,
+ SHA384,
+ SHA3,
+ RIPEMD160,
+} as const;
+
+const clearText = ref('Lorem ipsum')
+const hashedText = computed(() => algos[algo.value](clearText.value))
+const algo = ref<keyof typeof algos>('SHA256')
+
+const { copy } = useCopy({ source: hashedText, text: 'Token copied to the clipboard' })
+</script>
+
+<style lang="scss" scoped>
+</style> \ No newline at end of file