-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(new tool): WPA PSK Raw Key Generator
Fix #1236
- Loading branch information
Showing
6 changed files
with
114 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Wifi } from '@vicons/tabler'; | ||
import { defineTool } from '../tool'; | ||
|
||
export const tool = defineTool({ | ||
name: 'WPA PSK generator', | ||
path: '/wpa-psk-generator', | ||
description: 'WPA Pre-shared Key Generator to convert a WPA passphrase and SSID to the 256-bit pre-shared ("raw") key', | ||
keywords: ['wpa', 'psk', 'pre', 'shared', 'key', 'ssid', 'passphrase', 'generator'], | ||
component: () => import('./wpa-psk-generator.vue'), | ||
icon: Wifi, | ||
createdAt: new Date('2024-08-15'), | ||
}); |
12 changes: 12 additions & 0 deletions
12
src/tools/wpa-psk-generator/wpa-psk-generator.service.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { generateWpaPskRawKey } from './wpa-psk-generator.service'; | ||
|
||
describe('wpa-psk-generator', () => { | ||
it('generateWpaPskRawKey should generate raw key', () => { | ||
expect(generateWpaPskRawKey('test', 'test')).to.deep.eq({ | ||
passphrase: 'test', | ||
psk: 'd630c5513becfd3952432bd7fcf098b7a40907f3214cf43551f1b8cfda873eccd55e2e0c6b8fed55feecdd7f21db4fb6b31c602fe3f5e58e7edd462b12e4acc4632aa41c4755646b8a52826cb76f3a984571c4cfc73a1a2684f55790fac9e1f6c6002faedcb6c2d47a3678139027b95641efbcecd934b712bf48db71a76d8915', | ||
ssid: 'test', | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import CryptoJS from 'crypto-js'; | ||
import pbkdf2 from 'crypto-js/pbkdf2'; | ||
|
||
export function generateWpaPskRawKey(ssid: string, passphrase: string) { | ||
const psk = pbkdf2(passphrase, ssid, { | ||
keySize: 32, | ||
iterations: 4096, | ||
hasher: CryptoJS.algo.SHA1, | ||
}).toString(CryptoJS.enc.Hex); | ||
return { | ||
ssid, | ||
passphrase, | ||
psk, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<script setup lang="ts"> | ||
import { generateWpaPskRawKey } from './wpa-psk-generator.service'; | ||
import { useValidation } from '@/composable/validation'; | ||
const ssid = ref(''); | ||
const passphrase = ref(''); | ||
const wpaPSKRawKey = ref(''); | ||
function computeRawKey() { | ||
try { | ||
wpaPSKRawKey.value = generateWpaPskRawKey(ssid.value, passphrase.value)?.psk; | ||
} | ||
catch (e: any) { | ||
wpaPSKRawKey.value = e.toString(); | ||
} | ||
} | ||
const ssidValidation = useValidation({ | ||
source: ssid, | ||
rules: [ | ||
{ | ||
validator: v => v !== '', | ||
message: 'SSID must not be empty.', | ||
}, | ||
], | ||
}); | ||
</script> | ||
|
||
<template> | ||
<div style="max-width: 600px;"> | ||
<c-card title="Wifi Infos" mb-2> | ||
<c-input-text | ||
v-model:value="ssid" | ||
label="SSID" | ||
label-position="left" | ||
placeholder="Put your SSID here..." | ||
:validation="ssidValidation" | ||
mb-2 | ||
/> | ||
|
||
<c-input-text | ||
v-model:value="passphrase" | ||
label="Passphrase" | ||
label-position="left" | ||
placeholder="Put your Passphrase here..." | ||
mb-2 | ||
/> | ||
|
||
<div flex justify-center> | ||
<n-button @click="computeRawKey()">Compute</n-button> | ||
Check warning on line 50 in src/tools/wpa-psk-generator/wpa-psk-generator.vue GitHub Actions / ci
|
||
</div> | ||
</c-card> | ||
|
||
<c-card title="WPA PSK Raw Key (256 bits)"> | ||
<TextareaCopyable :value="wpaPSKRawKey" /> | ||
</c-card> | ||
</div> | ||
</template> |