Compare commits

..
Author SHA1 Message Date
sharevb aa0f705a63 feat(new tool): PGP Keygen
Fix part of #945 and part of #451
2024-04-28 19:03:52 +02:00
9 changed files with 260 additions and 753 deletions

No files matched your search

+2 -3
View File
@@ -78,7 +78,6 @@ declare module '@vue/runtime-core' {
Encryption: typeof import('./src/tools/encryption/encryption.vue')['default']
EtaCalculator: typeof import('./src/tools/eta-calculator/eta-calculator.vue')['default']
FavoriteButton: typeof import('./src/components/FavoriteButton.vue')['default']
FileType: typeof import('./src/tools/file-type/file-type.vue')['default']
FormatTransformer: typeof import('./src/components/FormatTransformer.vue')['default']
GitMemo: typeof import('./src/tools/git-memo/git-memo.vue')['default']
'GitMemo.content': typeof import('./src/tools/git-memo/git-memo.content.md')['default']
@@ -136,19 +135,19 @@ declare module '@vue/runtime-core' {
NH1: typeof import('naive-ui')['NH1']
NH3: typeof import('naive-ui')['NH3']
NIcon: typeof import('naive-ui')['NIcon']
NInput: typeof import('naive-ui')['NInput']
NInputNumber: typeof import('naive-ui')['NInputNumber']
NLayout: typeof import('naive-ui')['NLayout']
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
NMenu: typeof import('naive-ui')['NMenu']
NScrollbar: typeof import('naive-ui')['NScrollbar']
NSpin: typeof import('naive-ui')['NSpin']
NSwitch: typeof import('naive-ui')['NSwitch']
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default']
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']
PdfSignatureChecker: typeof import('./src/tools/pdf-signature-checker/pdf-signature-checker.vue')['default']
PdfSignatureDetails: typeof import('./src/tools/pdf-signature-checker/components/pdf-signature-details.vue')['default']
PercentageCalculator: typeof import('./src/tools/percentage-calculator/percentage-calculator.vue')['default']
PgpKeygen: typeof import('./src/tools/pgp-keygen/pgp-keygen.vue')['default']
PhoneParserAndFormatter: typeof import('./src/tools/phone-parser-and-formatter/phone-parser-and-formatter.vue')['default']
QrCodeGenerator: typeof import('./src/tools/qr-code-generator/qr-code-generator.vue')['default']
RandomPortGenerator: typeof import('./src/tools/random-port-generator/random-port-generator.vue')['default']
+1 -2
View File
@@ -60,7 +60,6 @@
"emojilib": "^3.0.10",
"figlet": "^1.7.0",
"figue": "^1.2.0",
"file-type": "^19.0.0",
"fuse.js": "^6.6.2",
"highlight.js": "^11.7.0",
"iarna-toml-esm": "^3.0.5",
@@ -76,6 +75,7 @@
"naive-ui": "^2.35.0",
"netmask": "^2.0.2",
"node-forge": "^1.3.1",
"openpgp": "^5.11.1",
"oui-data": "^1.0.10",
"pdf-signature-reader": "^1.4.2",
"pinia": "^2.0.34",
@@ -87,7 +87,6 @@
"unicode-emoji-json": "^0.4.0",
"unplugin-auto-import": "^0.16.4",
"uuid": "^9.0.0",
"vite-plugin-node-polyfills": "^0.21.0",
"vue": "^3.3.4",
"vue-i18n": "^9.9.1",
"vue-router": "^4.1.6",
+94 -655
View File
File diff suppressed because it is too large. Load diff
-76
View File
@@ -1,76 +0,0 @@
<script setup lang="ts">
import type { FileTypeResult } from 'file-type';
import { fileTypeFromBuffer } from 'file-type';
import InputCopyable from '../../components/InputCopyable.vue';
const status = ref<'idle' | 'done' | 'error' | 'processing'>('idle');
const file = ref<File | null>(null);
const type = ref<FileTypeResult | undefined>(undefined);
async function onFileUploaded(uploadedFile: File) {
file.value = uploadedFile;
const fileBuffer = await uploadedFile.arrayBuffer();
status.value = 'processing';
try {
type.value = await fileTypeFromBuffer(new Uint8Array(fileBuffer.slice(0, 4096)));
status.value = 'done';
}
catch (e) {
status.value = 'error';
}
}
</script>
<template>
<div>
<div style="flex: 0 0 100%" mb-3>
<div mx-auto max-w-600px>
<c-file-upload
title="Drag and drop a file here, or click to select a file"
@file-upload="onFileUploaded"
/>
</div>
</div>
<div mt-3 flex justify-center>
<c-card v-if="status === 'done'" title="Information">
<InputCopyable
:value="file?.name || ''"
label="File name:"
label-position="left"
label-width="100px"
label-align="right"
readonly
mt-2
/>
<InputCopyable
:value="type?.ext || '<unknown>'"
label="Extension:"
label-position="left"
label-width="100px"
label-align="right"
readonly
mt-2
/>
<InputCopyable
:value="type?.mime || '<unknown>'"
label="MIME Type:"
label-position="left"
label-width="100px"
label-align="right"
readonly
mt-2
/>
</c-card>
<c-alert v-if="status === 'error'" type="error">
An error occured processing {{ file?.name }}.
</c-alert>
<n-spin
v-if="status === 'processing'"
size="small"
/>
</div>
</div>
</template>
-12
View File
@@ -1,12 +0,0 @@
import { File } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'File Type Detector',
path: '/file-type',
description: 'Identify the type of a file',
keywords: ['file', 'type', 'identify', 'detector'],
component: () => import('./file-type.vue'),
icon: File,
createdAt: new Date('2024-04-20'),
});
+15 -3
View File
@@ -6,7 +6,7 @@ import { tool as asciiTextDrawer } from './ascii-text-drawer';
import { tool as textToUnicode } from './text-to-unicode';
import { tool as safelinkDecoder } from './safelink-decoder';
import { tool as fileType } from './file-type';
import { tool as pgpKeygen } from './pgp-keygen';
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
import { tool as numeronymGenerator } from './numeronym-generator';
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -86,7 +86,20 @@ import { tool as yamlViewer } from './yaml-viewer';
export const toolsByCategory: ToolCategory[] = [
{
name: 'Crypto',
components: [tokenGenerator, hashText, bcrypt, uuidGenerator, ulidGenerator, cypher, bip39, hmacGenerator, rsaKeyPairGenerator, passwordStrengthAnalyser, pdfSignatureChecker],
components: [
tokenGenerator,
hashText,
bcrypt,
uuidGenerator,
ulidGenerator,
cypher,
bip39,
hmacGenerator,
rsaKeyPairGenerator,
passwordStrengthAnalyser,
pdfSignatureChecker,
pgpKeygen,
],
},
{
name: 'Converter',
@@ -149,7 +162,6 @@ export const toolsByCategory: ToolCategory[] = [
dockerRunToDockerComposeConverter,
xmlFormatter,
yamlViewer,
fileType,
],
},
{
+12
View File
@@ -0,0 +1,12 @@
import { Certificate } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'PGP keygen',
path: '/pgp-key-pair-generator',
description: 'Generate new random PGP private and public keys (with or without passphrase).',
keywords: ['pgp', 'key', 'pair', 'generator', 'public', 'private', 'secret', 'ssh', 'pem', 'passphrase', 'password'],
component: () => import('./pgp-keygen.vue'),
icon: Certificate,
createdAt: new Date('2024-04-20'),
});
+136
View File
@@ -0,0 +1,136 @@
<script setup lang="ts">
import * as openpgp from 'openpgp';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { useValidation } from '@/composable/validation';
import { computedRefreshableAsync } from '@/composable/computedRefreshable';
const bits = ref(4096);
const username = ref('');
const useremail = ref('');
const password = ref('');
const format = useStorage('pgp-key-pair-generator:format', 'curve25519');
const formats = [
'rsa',
'curve25519',
'ed25519',
'p256', 'p384', 'p521',
'brainpoolP256r1', 'brainpoolP384r1', 'brainpoolP512r1',
'secp256k1',
];
const { attrs: bitsValidationAttrs } = useValidation({
source: bits,
rules: [
{
message: 'Bits should be 256 <= bits <= 16384 and be a multiple of 8',
validator: value => value >= 256 && value <= 16384 && value % 8 === 0,
},
],
});
const [certs, refreshCerts] = computedRefreshableAsync(
async () => {
const formatValue = format.value;
const passphrase = password.value;
const name = username.value;
const email = useremail.value;
const rsaBits = bits.value;
try {
if (format.value === 'rsa') {
const { privateKey, publicKey } = await openpgp.generateKey({
type: 'rsa', // Type of the key
rsaBits, // RSA key size (defaults to 4096 bits)
userIDs: [{ name, email }], // you can pass multiple user IDs
passphrase, // protects the private key
format: 'armored',
});
return { privateKey, publicKey, revocationCertificate: '' };
}
const { privateKey, publicKey, revocationCertificate } = await openpgp.generateKey({
type: 'ecc', // Type of the key, defaults to ECC
curve: formatValue as openpgp.EllipticCurveName, // ECC curve name, defaults to curve25519
userIDs: [{ name, email }], // you can pass multiple user IDs
passphrase, // protects the private key
format: 'armored',
});
return { privateKey, publicKey, revocationCertificate };
}
catch (e: any) {
return { privateKey: `#${e.toString()}`, publicKey: `#${e.toString()}`, revocationCertificate: '' };
}
}, { privateKey: '', publicKey: '', revocationCertificate: '' },
);
</script>
<template>
<div>
<div mb-4>
<div style="flex: 0 0 100%">
<div item-style="flex: 1 1 0" style="max-width: 600px" mx-auto flex gap-3>
<c-select
v-model:value="format"
label-position="left"
label="Format:"
:options="formats"
placeholder="Select a key format"
/>
<n-form-item v-if="format === 'rsa'" label="RSA Bits :" v-bind="bitsValidationAttrs as any" label-placement="left">
<n-input-number v-model:value="bits" min="256" max="16384" step="8" />
</n-form-item>
</div>
</div>
</div>
<div>
<n-form-item label="User Name :" label-placement="left">
<n-input
v-model:value="username"
type="text"
placeholder="User Name"
/>
</n-form-item>
<n-form-item label="User Email :" label-placement="left">
<n-input
v-model:value="useremail"
:input-props="{ type: 'email' }"
placeholder="User Email"
/>
</n-form-item>
<n-form-item label="Passphrase :" label-placement="left">
<n-input
v-model:value="password"
type="password"
show-password-on="mousedown"
placeholder="Passphrase"
/>
</n-form-item>
<div text-center>
<c-button @click="refreshCerts">
Refresh key-pair
</c-button>
</div>
</div>
<div>
<h3>Public key</h3>
<TextareaCopyable :value="certs?.publicKey || ''" word-wrap="true" />
</div>
<div>
<h3>Private key</h3>
<TextareaCopyable :value="certs?.privateKey || ''" word-wrap="true" />
</div>
<div>
<h3>Revocation Certificate</h3>
<TextareaCopyable :value="certs?.revocationCertificate || ''" word-wrap="true" />
</div>
</div>
</template>
-2
View File
@@ -15,7 +15,6 @@ import { VitePWA } from 'vite-plugin-pwa';
import markdown from 'vite-plugin-vue-markdown';
import svgLoader from 'vite-svg-loader';
import { configDefaults } from 'vitest/config';
import { nodePolyfills } from 'vite-plugin-node-polyfills'
const baseUrl = process.env.BASE_URL ?? '/';
@@ -98,7 +97,6 @@ export default defineConfig({
resolvers: [NaiveUiResolver(), IconsResolver({ prefix: 'icon' })],
}),
Unocss(),
nodePolyfills(),
],
base: baseUrl,
resolve: {