feat(new tool): Niceware Bytes Passphrase Converter

This commit is contained in:
ShareVB committed 2025-10-05 23:09:59 +02:00
1 parent 330b18d945
commit 4119b049cf
5 files changed
+14376 -11254

No files matched your search

+1
View File
@@ -252,6 +252,7 @@
"netmask": "^2.0.2",
"netstack.js": "^2.1.2",
"nginx-config-formatter": "^1.4.5",
"niceware": "^4.0.0",
"node-forge": "^1.3.1",
"openai-chat-tokens": "^0.2.8",
"openpgp": "^6.2.0",
+14279 -11254
View File
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,13 @@
import { Binary } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Niceware Bytes to Passphrase',
path: '/niceware-bytes-to-passphrase',
description: 'Convert bytes array to passphrase and conversely',
keywords: ['niceware', 'bytes', 'passphrase'],
component: () => import('./niceware-bytes-to-passphrase.vue'),
icon: Binary,
createdAt: new Date('2025-10-05'),
category: 'Crypto',
});
@@ -0,0 +1,79 @@
<script setup lang="ts">
import hexArray from 'hex-array';
import { bytesToPassphrase, passphraseToBytes } from 'niceware';
const textInput = ref('');
const nicewareOutput = computed(() => {
try {
return bytesToPassphrase(hexArray.fromString(textInput.value)).join(' ');
}
catch (e: any) {
return e.toString();
}
});
const uppercase = ref(false);
const grouping = ref(0);
const rowlength = ref(0);
const nicewareInput = ref('');
const textOutput = computed(() => {
try {
return hexArray.toString(passphraseToBytes(nicewareInput.value.split(/\s+/)), {
uppercase: uppercase.value,
grouping: grouping.value,
rowlength: rowlength.value,
});
}
catch (e: any) {
return e.toString();
}
},
);
</script>
<template>
<c-card title="Hex Array to Niceware passphrase">
<c-input-text
v-model:value="textInput"
multiline
placeholder="Put your hex array here..."
rows="5"
label="Hex array to encode:"
raw-text
mb-5
/>
<n-form-item label="Converted Niceware passphrase:">
<textarea-copyable :value="nicewareOutput" />
</n-form-item>
</c-card>
<c-card title="Niceware passphrase to hex array">
<n-space align="baseline" justify="center" mb-1>
<n-form-item label="Uppercase" label-placement="left">
<n-switch v-model:value="uppercase" />
</n-form-item>
<n-form-item label="Group by" label-placement="left">
<n-input-number-i18n v-model:value="grouping" :min="0" style="width: 6em" mr-1 />
<span>(Digit 0 = No grouping)</span>
</n-form-item>
<n-form-item label="Split as row by" label-placement="left">
<n-input-number-i18n v-model:value="rowlength" :min="0" style="width: 6em" mr-1 />
<span>(Digit 0 = No row)</span>
</n-form-item>
</n-space>
<c-input-text
v-model:value="nicewareInput"
multiline
placeholder="Put your niceware passphrase here..."
rows="5"
label="Niceware passphrase to decode:"
mb-5
/>
<n-form-item label="Converted to Hex array:">
<textarea-copyable :value="textOutput" />
</n-form-item>
</c-card>
</template>
+4
View File
@@ -0,0 +1,4 @@
declare module 'niceware' {
export function bytesToPassphrase(bytes: Uint8Array): string[];
export function passphraseToBytes(words: string[]): Uint8Array;
}