Skip to content

Commit

Permalink
fix(lint): lint issue fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnydanu committed Oct 28, 2024
1 parent 1493f9a commit 08aa02c
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 58 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test, expect } from '@playwright/test';
import { expect, test } from '@playwright/test';

test.describe('Tool - Argon2 hash generator', () => {
test.beforeEach(async ({ page }) => {
Expand All @@ -12,13 +12,13 @@ test.describe('Tool - Argon2 hash generator', () => {
test('hash a string a verify that the result match', async ({ page }) => {
await page.getByTestId('input').fill('azerty');

await new Promise((resolve) => setTimeout(resolve, 500));
await new Promise(resolve => setTimeout(resolve, 500));
const hash = await page.getByTestId('hash').inputValue();

await page.getByTestId('compare-string').fill('azerty');
await page.getByTestId('compare-hash').fill(hash);

await new Promise((resolve) => setTimeout(resolve, 500));
await new Promise(resolve => setTimeout(resolve, 500));
const doTheyMatch = await page.getByTestId('do-they-match').innerText();

expect(doTheyMatch.trim()).toEqual('Yes');
Expand Down
70 changes: 36 additions & 34 deletions src/tools/argon2-hash-generator/argon2-hash-generator.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
<script setup lang="ts">
import { argon2Verify, argon2id } from 'hash-wasm';
import { useCopy } from '@/composable/copy';
const input = ref('');
const iterations = ref(32);
const memorySize = ref(512);
const hashLength = ref(32);
const hashed = computedAsync(
async () =>
argon2id({
password: input.value,
salt: window.crypto.getRandomValues(new Uint8Array(16)),
parallelism: 1,
iterations: iterations.value,
memorySize: memorySize.value,
hashLength: hashLength.value,
outputType: 'encoded',
}),
'',
);
const { copy } = useCopy({ source: hashed, text: 'Hashed string copied to the clipboard' });
const compareString = ref('');
const compareHash = ref('');
const compareMatch = computedAsync(
() => argon2Verify({ password: compareString.value, hash: compareHash.value }),
false,
);
</script>

<template>
<n-card title="Hash">
<n-form label-width="120">
Expand Down Expand Up @@ -30,9 +62,11 @@
}"
/>
</n-form>
<br />
<br>
<n-space justify="center">
<n-button secondary @click="copy"> Copy hash </n-button>
<n-button secondary @click="copy">
Copy hash
</n-button>
</n-space>
</n-card>

Expand Down Expand Up @@ -73,35 +107,3 @@
</n-form>
</n-card>
</template>

<script setup lang="ts">
import { useCopy } from '@/composable/copy';
import { argon2id, argon2Verify } from 'hash-wasm';
const input = ref('');
const iterations = ref(32);
const memorySize = ref(512);
const hashLength = ref(32);
const hashed = computedAsync(
async () =>
argon2id({
password: input.value,
salt: window.crypto.getRandomValues(new Uint8Array(16)),
parallelism: 1,
iterations: iterations.value,
memorySize: memorySize.value,
hashLength: hashLength.value,
outputType: 'encoded',
}),
'',
);
const { copy } = useCopy({ source: hashed, text: 'Hashed string copied to the clipboard' });
const compareString = ref('');
const compareHash = ref('');
const compareMatch = computedAsync(
() => argon2Verify({ password: compareString.value, hash: compareHash.value }),
false,
);
</script>
43 changes: 24 additions & 19 deletions src/tools/bcrypt/bcrypt.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
<script setup lang="ts">
import { compareSync, hashSync } from 'bcryptjs';
import { useCopy } from '@/composable/copy';
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>

<template>
<n-card title="Hash">
<n-form label-width="120">
Expand All @@ -16,9 +30,11 @@
</n-form-item>
<n-input :value="hashed" readonly style="text-align: center" />
</n-form>
<br />
<br>
<n-space justify="center">
<n-button secondary @click="copy"> Copy hash </n-button>
<n-button secondary @click="copy">
Copy hash
</n-button>
</n-space>
</n-card>

Expand All @@ -45,24 +61,13 @@
/>
</n-form-item>
<n-form-item label="Do they match ? " label-placement="left" :show-feedback="false">
<n-tag v-if="compareMatch" :bordered="false" type="success" round>Yes</n-tag>
<n-tag v-else :bordered="false" type="error" round>No</n-tag>
<n-tag v-if="compareMatch" :bordered="false" type="success" round>
Yes
</n-tag>
<n-tag v-else :bordered="false" type="error" round>
No
</n-tag>
</n-form-item>
</n-form>
</n-card>
</template>

<script setup lang="ts">
import { compareSync, hashSync } from 'bcryptjs';
import { useThemeVars } from 'naive-ui';
import { useCopy } from '@/composable/copy';
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>
7 changes: 5 additions & 2 deletions src/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,14 @@ export const toolsByCategory: ToolCategory[] = [
bcrypt,
argon2HashGenerator,
uuidGenerator,
ulidGenerator, cypher,
ulidGenerator,
cypher,
bip39,
hmacGenerator,
rsaKeyPairGenerator,
, passwordStrengthAnalyser, pdfSignatureChecker],
passwordStrengthAnalyser,
pdfSignatureChecker,
],
},
{
name: 'Converter',
Expand Down

0 comments on commit 08aa02c

Please sign in to comment.