diff --git a/package.json b/package.json index f708199a..85e9e956 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "date-fns": "^2.29.3", "figue": "^1.2.0", "fuse.js": "^6.6.2", + "hash-wasm": "^4.9.0", "highlight.js": "^11.7.0", "json5": "^2.2.3", "jwt-decode": "^3.1.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1e1b8715..b1c5a0ec 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -64,6 +64,9 @@ dependencies: fuse.js: specifier: ^6.6.2 version: 6.6.2 + hash-wasm: + specifier: ^4.9.0 + version: 4.9.0 highlight.js: specifier: ^11.7.0 version: 11.7.0 @@ -5012,6 +5015,10 @@ packages: resolution: {integrity: sha512-WdZTbAByD+pHfl/g9QSsBIIwy8IT+EsPiKDs0KNX+zSHhdDLFKdZu0BQHljvO+0QI/BasbMSUa8wYNCZTvhslg==} dev: true + /hash-wasm@4.9.0: + resolution: {integrity: sha512-7SW7ejyfnRxuOc7ptQHSf4LDoZaWOivfzqw+5rpcQku0nHfmicPKE51ra9BiRLAmT8+gGLestr1XroUkqdjL6w==} + dev: false + /header-case@2.0.4: resolution: {integrity: sha512-H/vuk5TEEVZwrR0lp2zed9OCo1uAILMlx0JEMgC26rzyJJ3N1v6XkwHHXJQdR2doSjcGPM6OKPYoJgf0plJ11Q==} dependencies: diff --git a/src/tools/argon2-hash-generator/argon2-hash-generator.e2e.spec.ts b/src/tools/argon2-hash-generator/argon2-hash-generator.e2e.spec.ts new file mode 100644 index 00000000..4492c1ea --- /dev/null +++ b/src/tools/argon2-hash-generator/argon2-hash-generator.e2e.spec.ts @@ -0,0 +1,37 @@ +import { test, expect } from '@playwright/test'; + +test.describe('Tool - Argon2 hash generator', () => { + test.beforeEach(async ({ page }) => { + await page.goto('/argon2-hash-generator'); + }); + + test('Has correct title', async ({ page }) => { + await expect(page).toHaveTitle('Argon2 hash generator - IT Tools'); + }); + + 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)); + 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)); + const doTheyMatch = await page.getByTestId('do-they-match').innerText(); + + expect(doTheyMatch.trim()).toEqual('Yes'); + }); + + test('hash a string a verify that the does not result match another string', async ({ page }) => { + await page.getByTestId('input').fill('azerty'); + const hash = await page.getByTestId('hash').inputValue(); + + await page.getByTestId('compare-string').fill('NOT AZERTY'); + await page.getByTestId('compare-hash').fill(hash); + const doTheyMatch = await page.getByTestId('do-they-match').innerText(); + + expect(doTheyMatch.trim()).toEqual('No'); + }); +}); diff --git a/src/tools/argon2-hash-generator/argon2-hash-generator.vue b/src/tools/argon2-hash-generator/argon2-hash-generator.vue new file mode 100644 index 00000000..3f210202 --- /dev/null +++ b/src/tools/argon2-hash-generator/argon2-hash-generator.vue @@ -0,0 +1,107 @@ + + + diff --git a/src/tools/argon2-hash-generator/index.ts b/src/tools/argon2-hash-generator/index.ts new file mode 100644 index 00000000..26b12321 --- /dev/null +++ b/src/tools/argon2-hash-generator/index.ts @@ -0,0 +1,12 @@ +import { Lock } from '@vicons/tabler'; +import { defineTool } from '../tool'; + +export const tool = defineTool({ + name: 'Argon2 hash generator', + path: '/argon2-hash-generator', + description: 'Hash and compare string (password) using Argon2', + keywords: ['argon2', 'hash', 'generator', 'password', 'salt', 'crypto', 'security'], + component: () => import('./argon2-hash-generator.vue'), + icon: Lock, + createdAt: new Date('2023-04-16'), +}); diff --git a/src/tools/bcrypt/bcrypt.vue b/src/tools/bcrypt/bcrypt.vue index 4104c744..b0df627d 100644 --- a/src/tools/bcrypt/bcrypt.vue +++ b/src/tools/bcrypt/bcrypt.vue @@ -37,7 +37,7 @@ -
- {{ compareMatch ? 'Yes' : 'No' }} -
+ Yes + No
@@ -57,9 +56,6 @@ 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); @@ -70,13 +66,3 @@ const compareString = ref(''); const compareHash = ref(''); const compareMatch = computed(() => compareSync(compareString.value, compareHash.value)); - - diff --git a/src/tools/index.ts b/src/tools/index.ts index ad6167e1..dcd2fe3b 100644 --- a/src/tools/index.ts +++ b/src/tools/index.ts @@ -1,6 +1,7 @@ import { tool as base64FileConverter } from './base64-file-converter'; import { tool as base64StringConverter } from './base64-string-converter'; import { tool as basicAuthGenerator } from './basic-auth-generator'; +import { tool as argon2HashGenerator } from './argon2-hash-generator'; import { tool as httpStatusCodes } from './http-status-codes'; import { tool as yamlToJson } from './yaml-to-json-converter'; import { tool as jsonToYaml } from './json-to-yaml-converter'; @@ -56,7 +57,17 @@ import { tool as macAddressLookup } from './mac-address-lookup'; export const toolsByCategory: ToolCategory[] = [ { name: 'Crypto', - components: [tokenGenerator, hashText, bcrypt, uuidGenerator, cypher, bip39, hmacGenerator, rsaKeyPairGenerator], + components: [ + tokenGenerator, + hashText, + bcrypt, + argon2HashGenerator, + uuidGenerator, + cypher, + bip39, + hmacGenerator, + rsaKeyPairGenerator, + ], }, { name: 'Converter',