Skip to content

Commit 11f1fd6

Browse files
committed
Merge branch 'feat/wpa-psk-generator' into chore/all-my-stuffs
# Conflicts: # components.d.ts # src/tools/index.ts
2 parents e83678b + 96f6262 commit 11f1fd6

File tree

6 files changed

+102
-2
lines changed

6 files changed

+102
-2
lines changed

pnpm-lock.yaml

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tools/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import { tool as unicodeSearch } from './unicode-search';
5252
import { tool as vatValidator } from './vat-validator';
5353
import { tool as websocketTester } from './websocket-tester';
5454
import { tool as weekNumberConverter } from './week-number-converter';
55+
import { tool as wpaPskGenerator } from './wpa-psk-generator';
5556

5657
import { tool as cssXpathConverter } from './css-xpath-converter';
5758
import { tool as cssSelectorsMemo } from './css-selectors-memo';
@@ -223,6 +224,9 @@ export const toolsByCategory: ToolCategory[] = [
223224
pdfSignatureChecker,
224225
// pgpEncryption,
225226
rsaEcdsaSigning,
227+
passwordStrengthAnalyser,
228+
pdfSignatureChecker,
229+
wpaPskGenerator,
226230
],
227231
},
228232
{

src/tools/wpa-psk-generator/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Wifi } from '@vicons/tabler';
2+
import { defineTool } from '../tool';
3+
4+
export const tool = defineTool({
5+
name: 'WPA PSK generator',
6+
path: '/wpa-psk-generator',
7+
description: 'WPA Pre-shared Key Generator to convert a WPA passphrase and SSID to the 256-bit pre-shared ("raw") key',
8+
keywords: ['wpa', 'psk', 'pre', 'shared', 'key', 'ssid', 'passphrase', 'generator'],
9+
component: () => import('./wpa-psk-generator.vue'),
10+
icon: Wifi,
11+
createdAt: new Date('2024-08-15'),
12+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { describe, expect, it } from 'vitest';
2+
import { generateWpaPskRawKey } from './wpa-psk-generator.service';
3+
4+
describe('wpa-psk-generator', () => {
5+
it('generateWpaPskRawKey should generate raw key', () => {
6+
expect(generateWpaPskRawKey('test', 'test')).to.deep.eq({
7+
passphrase: 'test',
8+
psk: 'd630c5513becfd3952432bd7fcf098b7a40907f3214cf43551f1b8cfda873ecc',
9+
ssid: 'test',
10+
});
11+
expect(generateWpaPskRawKey('test', 'test')?.psk).toHaveLength(256 / 8 * 2);
12+
});
13+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import CryptoJS from 'crypto-js';
2+
import pbkdf2 from 'crypto-js/pbkdf2';
3+
4+
export function generateWpaPskRawKey(ssid: string, passphrase: string) {
5+
const psk = pbkdf2(passphrase, ssid, {
6+
keySize: 256 / 32,
7+
iterations: 4096,
8+
hasher: CryptoJS.algo.SHA1,
9+
}).toString(CryptoJS.enc.Hex);
10+
return {
11+
ssid,
12+
passphrase,
13+
psk,
14+
};
15+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<script setup lang="ts">
2+
import { generateWpaPskRawKey } from './wpa-psk-generator.service';
3+
import { useValidation } from '@/composable/validation';
4+
5+
const ssid = ref('');
6+
const passphrase = ref('');
7+
8+
const wpaPSKRawKey = ref('');
9+
function computeRawKey() {
10+
try {
11+
wpaPSKRawKey.value = generateWpaPskRawKey(ssid.value, passphrase.value)?.psk;
12+
}
13+
catch (e: any) {
14+
wpaPSKRawKey.value = e.toString();
15+
}
16+
}
17+
18+
const ssidValidation = useValidation({
19+
source: ssid,
20+
rules: [
21+
{
22+
validator: v => v !== '',
23+
message: 'SSID must not be empty.',
24+
},
25+
],
26+
});
27+
</script>
28+
29+
<template>
30+
<div style="max-width: 600px;">
31+
<c-card title="Wifi Infos" mb-2>
32+
<c-input-text
33+
v-model:value="ssid"
34+
label="SSID"
35+
label-position="left"
36+
placeholder="Put your SSID here..."
37+
:validation="ssidValidation"
38+
mb-2
39+
/>
40+
41+
<c-input-text
42+
v-model:value="passphrase"
43+
label="Passphrase"
44+
label-position="left"
45+
placeholder="Put your Passphrase here..."
46+
mb-2
47+
/>
48+
49+
<div flex justify-center>
50+
<n-button @click="computeRawKey()">Compute</n-button>
51+
</div>
52+
</c-card>
53+
54+
<c-card title="WPA PSK Raw Key (256 bits)">
55+
<TextareaCopyable :value="wpaPSKRawKey" />
56+
</c-card>
57+
</div>
58+
</template>

0 commit comments

Comments
 (0)