aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Corentin Thomasset <corentin.thomasset74@gmail.com> 2022-04-18 10:16:59 +0200
committerGravatar Corentin Thomasset <corentin.thomasset74@gmail.com> 2022-04-18 10:17:39 +0200
commit6d5856fa93d1ffbf71856c75adc24ad87dc4b49b (patch)
tree4c2ab731cb0a6a44cc10c28ea97f42994bf8d4c4 /src
parent2b89111cbbfd49604cd135fbba097d5d40da3182 (diff)
downloadit-tools-6d5856fa93d1ffbf71856c75adc24ad87dc4b49b.tar.gz
it-tools-6d5856fa93d1ffbf71856c75adc24ad87dc4b49b.tar.zst
it-tools-6d5856fa93d1ffbf71856c75adc24ad87dc4b49b.zip
feat(new-tool): bcrypt
Diffstat (limited to 'src')
-rw-r--r--src/tools/bcrypt/bcrypt.vue118
-rw-r--r--src/tools/bcrypt/index.ts11
-rw-r--r--src/tools/index.ts3
3 files changed, 131 insertions, 1 deletions
diff --git a/src/tools/bcrypt/bcrypt.vue b/src/tools/bcrypt/bcrypt.vue
new file mode 100644
index 0000000..5d546dc
--- /dev/null
+++ b/src/tools/bcrypt/bcrypt.vue
@@ -0,0 +1,118 @@
+<template>
+ <n-card title="Hash">
+ <n-form label-width="120">
+ <n-form-item
+ label="Your string: "
+ label-placement="left"
+ >
+ <n-input
+ v-model:value="input"
+ placeholder="Your string to bcrypt..."
+ autocomplete="off"
+ autocorrect="off"
+ autocapitalize="off"
+ spellcheck="false"
+ />
+ </n-form-item>
+ <n-form-item
+ label="Salt count: "
+ label-placement="left"
+ >
+ <n-input-number
+ v-model:value="saltCount"
+ placeholder="Salt rounds..."
+ :max="10"
+ :min="0"
+ style="width: 100%;"
+ />
+ </n-form-item>
+ <n-input
+ :value="hashed"
+ readonly
+ style="text-align: center;"
+ />
+ </n-form>
+ <br>
+ <n-space justify="center">
+ <n-button
+ secondary
+ @click="copy"
+ >
+ Copy hash
+ </n-button>
+ </n-space>
+ </n-card>
+
+ <br>
+ <n-card title="Compare string with hash">
+ <n-form label-width="120">
+ <n-form-item
+ label="Your string: "
+ label-placement="left"
+ >
+ <n-input
+ v-model:value="compareString"
+ placeholder="Your string to compare..."
+ autocomplete="off"
+ autocorrect="off"
+ autocapitalize="off"
+ spellcheck="false"
+ />
+ </n-form-item>
+ <n-form-item
+ label="Your hash: "
+ label-placement="left"
+ >
+ <n-input
+ v-model:value="compareHash"
+ placeholder="Your hahs to compare..."
+ autocomplete="off"
+ autocorrect="off"
+ autocapitalize="off"
+ spellcheck="false"
+ />
+ </n-form-item>
+ <n-form-item
+ label="Do they match ? "
+ label-placement="left"
+ :show-feedback="false"
+ >
+ <div
+ class="compare-result"
+ :class="{positive:compareMatch}"
+ >
+ {{ compareMatch ? 'Yes' : 'No' }}
+ </div>
+ </n-form-item>
+ </n-form>
+ </n-card>
+</template>
+
+<script setup lang="ts">
+import { computed, ref } from 'vue';
+import {hashSync, compareSync} from 'bcryptjs'
+import { useCopy } from '@/composable/copy';
+import { useThemeVars } from 'naive-ui';
+
+const themeVars = useThemeVars()
+
+const input = ref('')
+const saltCount = ref(10)
+const hashed = computed(() => hashSync(input.value, saltCount.value))
+const {copy} = useCopy({source: hashed, text:'Hashed string copied to the clipboard'})
+
+const compareString = ref('')
+const compareHash = ref('')
+const compareMatch = computed(() => compareSync(compareString.value, compareHash.value))
+
+</script>
+
+<style lang="less" scoped>
+.compare-result {
+ color: v-bind('themeVars.errorColor');
+
+ &.positive {
+ color: v-bind('themeVars.successColor')
+ }
+}
+</style> \ No newline at end of file
diff --git a/src/tools/bcrypt/index.ts b/src/tools/bcrypt/index.ts
new file mode 100644
index 0000000..9108853
--- /dev/null
+++ b/src/tools/bcrypt/index.ts
@@ -0,0 +1,11 @@
+import { LockSquare } from '@vicons/tabler';
+import type { ITool } from './../Tool';
+
+export const tool: ITool = {
+ name: 'Bcrypt',
+ path: '/bcrypt',
+ description: 'Hash and compare text string using bcrypt. Bcrypt is a password-hashing function based on the Blowfish cipher.',
+ keywords: ['bcrypt', 'hash', 'compare', 'password', 'salt', 'round', 'storage', 'crypto'],
+ component: () => import('./bcrypt.vue'),
+ icon: LockSquare,
+};
diff --git a/src/tools/index.ts b/src/tools/index.ts
index 9ca90dd..bc29ac6 100644
--- a/src/tools/index.ts
+++ b/src/tools/index.ts
@@ -1,6 +1,7 @@
import { LockOpen } from '@vicons/tabler';
import type { ToolCategory } from './Tool';
+import { tool as bcrypt } from './bcrypt';
import { tool as caseConverter } from './case-converter';
import { tool as colorConverter } from './color-converter';
import { tool as qrCodeGenerator } from './qr-code-generator';
@@ -24,7 +25,7 @@ export const toolsByCategory: ToolCategory[] = [
{
name: 'Crypto',
icon: LockOpen,
- components: [tokenGenerator, hashText, uuidGenerator, cypher, bip39],
+ components: [tokenGenerator, hashText, bcrypt, uuidGenerator, cypher, bip39],
},
{
name: 'Converter',