mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-05 13:57:10 -04:00
feat(new tool): Ed25519 Key Pair Generator
Fix #281 (ed25519 key pairs, passphrase and openssh format) Supports generation in PEM, PKCS#8, OpenSSH Standard (with or without passphrase), OpenSSH (new format) and PuTTY (no passphrase)
This commit is contained in:
parent
60841f6e4a
commit
ca44c5c52a
5 changed files with 138 additions and 47 deletions
47
components.d.ts
vendored
47
components.d.ts
vendored
|
@ -70,6 +70,7 @@ declare module '@vue/runtime-core' {
|
||||||
DiffViewer: typeof import('./src/tools/json-diff/diff-viewer/diff-viewer.vue')['default']
|
DiffViewer: typeof import('./src/tools/json-diff/diff-viewer/diff-viewer.vue')['default']
|
||||||
DockerRunToDockerComposeConverter: typeof import('./src/tools/docker-run-to-docker-compose-converter/docker-run-to-docker-compose-converter.vue')['default']
|
DockerRunToDockerComposeConverter: typeof import('./src/tools/docker-run-to-docker-compose-converter/docker-run-to-docker-compose-converter.vue')['default']
|
||||||
DynamicValues: typeof import('./src/tools/benchmark-builder/dynamic-values.vue')['default']
|
DynamicValues: typeof import('./src/tools/benchmark-builder/dynamic-values.vue')['default']
|
||||||
|
Ed25519KeyPairGenerator: typeof import('./src/tools/ed25519-key-pair-generator/ed25519-key-pair-generator.vue')['default']
|
||||||
Editor: typeof import('./src/tools/html-wysiwyg-editor/editor/editor.vue')['default']
|
Editor: typeof import('./src/tools/html-wysiwyg-editor/editor/editor.vue')['default']
|
||||||
EmojiCard: typeof import('./src/tools/emoji-picker/emoji-card.vue')['default']
|
EmojiCard: typeof import('./src/tools/emoji-picker/emoji-card.vue')['default']
|
||||||
EmojiGrid: typeof import('./src/tools/emoji-picker/emoji-grid.vue')['default']
|
EmojiGrid: typeof import('./src/tools/emoji-picker/emoji-grid.vue')['default']
|
||||||
|
@ -88,28 +89,9 @@ declare module '@vue/runtime-core' {
|
||||||
HttpStatusCodes: typeof import('./src/tools/http-status-codes/http-status-codes.vue')['default']
|
HttpStatusCodes: typeof import('./src/tools/http-status-codes/http-status-codes.vue')['default']
|
||||||
IbanValidatorAndParser: typeof import('./src/tools/iban-validator-and-parser/iban-validator-and-parser.vue')['default']
|
IbanValidatorAndParser: typeof import('./src/tools/iban-validator-and-parser/iban-validator-and-parser.vue')['default']
|
||||||
'IconMdi:brushVariant': typeof import('~icons/mdi/brush-variant')['default']
|
'IconMdi:brushVariant': typeof import('~icons/mdi/brush-variant')['default']
|
||||||
'IconMdi:contentCopy': typeof import('~icons/mdi/content-copy')['default']
|
|
||||||
'IconMdi:kettleSteamOutline': typeof import('~icons/mdi/kettle-steam-outline')['default']
|
'IconMdi:kettleSteamOutline': typeof import('~icons/mdi/kettle-steam-outline')['default']
|
||||||
IconMdiArrowDown: typeof import('~icons/mdi/arrow-down')['default']
|
|
||||||
IconMdiArrowRightBottom: typeof import('~icons/mdi/arrow-right-bottom')['default']
|
|
||||||
IconMdiCamera: typeof import('~icons/mdi/camera')['default']
|
|
||||||
IconMdiChevronDown: typeof import('~icons/mdi/chevron-down')['default']
|
|
||||||
IconMdiChevronRight: typeof import('~icons/mdi/chevron-right')['default']
|
|
||||||
IconMdiClose: typeof import('~icons/mdi/close')['default']
|
|
||||||
IconMdiContentCopy: typeof import('~icons/mdi/content-copy')['default']
|
IconMdiContentCopy: typeof import('~icons/mdi/content-copy')['default']
|
||||||
IconMdiDeleteOutline: typeof import('~icons/mdi/delete-outline')['default']
|
|
||||||
IconMdiDownload: typeof import('~icons/mdi/download')['default']
|
|
||||||
IconMdiEye: typeof import('~icons/mdi/eye')['default']
|
|
||||||
IconMdiEyeOff: typeof import('~icons/mdi/eye-off')['default']
|
|
||||||
IconMdiHeart: typeof import('~icons/mdi/heart')['default']
|
|
||||||
IconMdiPause: typeof import('~icons/mdi/pause')['default']
|
|
||||||
IconMdiPlay: typeof import('~icons/mdi/play')['default']
|
|
||||||
IconMdiRecord: typeof import('~icons/mdi/record')['default']
|
|
||||||
IconMdiRefresh: typeof import('~icons/mdi/refresh')['default']
|
|
||||||
IconMdiSearch: typeof import('~icons/mdi/search')['default']
|
|
||||||
IconMdiTranslate: typeof import('~icons/mdi/translate')['default']
|
IconMdiTranslate: typeof import('~icons/mdi/translate')['default']
|
||||||
IconMdiTriangleDown: typeof import('~icons/mdi/triangle-down')['default']
|
|
||||||
IconMdiVideo: typeof import('~icons/mdi/video')['default']
|
|
||||||
InputCopyable: typeof import('./src/components/InputCopyable.vue')['default']
|
InputCopyable: typeof import('./src/components/InputCopyable.vue')['default']
|
||||||
IntegerBaseConverter: typeof import('./src/tools/integer-base-converter/integer-base-converter.vue')['default']
|
IntegerBaseConverter: typeof import('./src/tools/integer-base-converter/integer-base-converter.vue')['default']
|
||||||
Ipv4AddressConverter: typeof import('./src/tools/ipv4-address-converter/ipv4-address-converter.vue')['default']
|
Ipv4AddressConverter: typeof import('./src/tools/ipv4-address-converter/ipv4-address-converter.vue')['default']
|
||||||
|
@ -136,39 +118,12 @@ declare module '@vue/runtime-core' {
|
||||||
MenuLayout: typeof import('./src/components/MenuLayout.vue')['default']
|
MenuLayout: typeof import('./src/components/MenuLayout.vue')['default']
|
||||||
MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default']
|
MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default']
|
||||||
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
|
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
|
||||||
NAlert: typeof import('naive-ui')['NAlert']
|
|
||||||
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
|
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
|
||||||
NCheckbox: typeof import('naive-ui')['NCheckbox']
|
|
||||||
NCode: typeof import('naive-ui')['NCode']
|
|
||||||
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
|
|
||||||
NColorPicker: typeof import('naive-ui')['NColorPicker']
|
|
||||||
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
|
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
|
||||||
NDatePicker: typeof import('naive-ui')['NDatePicker']
|
|
||||||
NDivider: typeof import('naive-ui')['NDivider']
|
|
||||||
NDynamicInput: typeof import('naive-ui')['NDynamicInput']
|
|
||||||
NEllipsis: typeof import('naive-ui')['NEllipsis']
|
NEllipsis: typeof import('naive-ui')['NEllipsis']
|
||||||
NForm: typeof import('naive-ui')['NForm']
|
|
||||||
NFormItem: typeof import('naive-ui')['NFormItem']
|
|
||||||
NGi: typeof import('naive-ui')['NGi']
|
|
||||||
NGrid: typeof import('naive-ui')['NGrid']
|
|
||||||
NH1: typeof import('naive-ui')['NH1']
|
NH1: typeof import('naive-ui')['NH1']
|
||||||
NH2: typeof import('naive-ui')['NH2']
|
|
||||||
NH3: typeof import('naive-ui')['NH3']
|
NH3: typeof import('naive-ui')['NH3']
|
||||||
NIcon: typeof import('naive-ui')['NIcon']
|
NIcon: typeof import('naive-ui')['NIcon']
|
||||||
NImage: typeof import('naive-ui')['NImage']
|
|
||||||
NInputGroup: typeof import('naive-ui')['NInputGroup']
|
|
||||||
NInputGroupLabel: typeof import('naive-ui')['NInputGroupLabel']
|
|
||||||
NInputNumber: typeof import('naive-ui')['NInputNumber']
|
|
||||||
NLayout: typeof import('naive-ui')['NLayout']
|
|
||||||
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
|
|
||||||
NMenu: typeof import('naive-ui')['NMenu']
|
|
||||||
NProgress: typeof import('naive-ui')['NProgress']
|
|
||||||
NScrollbar: typeof import('naive-ui')['NScrollbar']
|
|
||||||
NSlider: typeof import('naive-ui')['NSlider']
|
|
||||||
NStatistic: typeof import('naive-ui')['NStatistic']
|
|
||||||
NSwitch: typeof import('naive-ui')['NSwitch']
|
|
||||||
NTable: typeof import('naive-ui')['NTable']
|
|
||||||
NTag: typeof import('naive-ui')['NTag']
|
|
||||||
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
|
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']
|
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']
|
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
import sshpk from 'sshpk';
|
||||||
|
|
||||||
|
export { generateKeyPair };
|
||||||
|
|
||||||
|
async function generateKeyPair(config: {
|
||||||
|
password?: string
|
||||||
|
format?: sshpk.PrivateKeyFormatType
|
||||||
|
comment?: string
|
||||||
|
} = {}) {
|
||||||
|
const privKey = sshpk.generatePrivateKey('ed25519');
|
||||||
|
privKey.comment = config?.comment;
|
||||||
|
|
||||||
|
const pubFormat = config.format ?? 'ssh';
|
||||||
|
let privFormat: sshpk.PrivateKeyFormatType = config.format ?? 'ssh';
|
||||||
|
if (privFormat === 'ssh') {
|
||||||
|
privFormat = 'ssh-private';
|
||||||
|
}
|
||||||
|
const pubKey = privKey.toPublic();
|
||||||
|
return {
|
||||||
|
publicKey: pubKey.toString(pubFormat),
|
||||||
|
privateKey: config?.password
|
||||||
|
? privKey.toString(privFormat,
|
||||||
|
{
|
||||||
|
passphrase: config?.password,
|
||||||
|
comment: config?.comment,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: privKey.toString(privFormat, { comment: config?.comment }),
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import type sshpk from 'sshpk';
|
||||||
|
import { generateKeyPair } from './ed25519-key-pair-generator.service';
|
||||||
|
import TextareaCopyable from '@/components/TextareaCopyable.vue';
|
||||||
|
import { withDefaultOnErrorAsync } from '@/utils/defaults';
|
||||||
|
import { computedRefreshableAsync } from '@/composable/computedRefreshable';
|
||||||
|
|
||||||
|
const password = ref('');
|
||||||
|
const comment = ref('');
|
||||||
|
const emptyCerts = { publicKey: '', privateKey: '' };
|
||||||
|
|
||||||
|
const format = useStorage('ed25519-key-pair-generator:format', 'ssh');
|
||||||
|
const formatOptions = [
|
||||||
|
{ value: 'pem', label: 'PEM' },
|
||||||
|
{ value: 'pkcs8', label: 'PKCS#8' },
|
||||||
|
{ value: 'ssh', label: 'OpenSSH Standard' },
|
||||||
|
{ value: 'openssh', label: 'OpenSSH New' },
|
||||||
|
{ value: 'putty', label: 'PuTTY' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const supportsPassphrase = computed(() => format.value === 'ssh');
|
||||||
|
|
||||||
|
const [certs, refreshCerts] = computedRefreshableAsync(
|
||||||
|
() => withDefaultOnErrorAsync(() => generateKeyPair(
|
||||||
|
{
|
||||||
|
password: password.value,
|
||||||
|
format: format.value as sshpk.PrivateKeyFormatType,
|
||||||
|
comment: comment.value,
|
||||||
|
},
|
||||||
|
), emptyCerts),
|
||||||
|
emptyCerts,
|
||||||
|
);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<n-space mb-2>
|
||||||
|
<c-select
|
||||||
|
v-model:value="format"
|
||||||
|
label-position="left"
|
||||||
|
label="Format:"
|
||||||
|
:options="formatOptions"
|
||||||
|
placeholder="Select a key format"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<n-form-item v-if="supportsPassphrase" label="Passphrase :" label-placement="left">
|
||||||
|
<n-input
|
||||||
|
v-model:value="password"
|
||||||
|
type="password"
|
||||||
|
show-password-on="mousedown"
|
||||||
|
placeholder="Passphrase"
|
||||||
|
/>
|
||||||
|
</n-form-item>
|
||||||
|
</n-space>
|
||||||
|
|
||||||
|
<n-space mb-2>
|
||||||
|
<n-form-item label="Comment :" label-placement="left">
|
||||||
|
<n-input
|
||||||
|
v-model:value="comment"
|
||||||
|
type="text"
|
||||||
|
placeholder="Comment"
|
||||||
|
/>
|
||||||
|
</n-form-item>
|
||||||
|
|
||||||
|
<c-button @click="refreshCerts">
|
||||||
|
Refresh key-pair
|
||||||
|
</c-button>
|
||||||
|
</n-space>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<h3>Public key</h3>
|
||||||
|
<TextareaCopyable :value="certs.publicKey" :word-wrap="true" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<h3>Private key</h3>
|
||||||
|
<TextareaCopyable :value="certs.privateKey" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
12
src/tools/ed25519-key-pair-generator/index.ts
Normal file
12
src/tools/ed25519-key-pair-generator/index.ts
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import { Certificate } from '@vicons/tabler';
|
||||||
|
import { defineTool } from '../tool';
|
||||||
|
|
||||||
|
export const tool = defineTool({
|
||||||
|
name: 'Ed25519 key pair generator',
|
||||||
|
path: '/ed25519-key-pair-generator',
|
||||||
|
description: 'Generate new random Ed25519 private and public keys (with or without passphrase).',
|
||||||
|
keywords: ['ed25519', 'key', 'pair', 'generator', 'public', 'private', 'secret', 'ssh', 'pem', 'passphrase', 'password'],
|
||||||
|
component: () => import('./ed25519-key-pair-generator.vue'),
|
||||||
|
icon: Certificate,
|
||||||
|
createdAt: new Date('2024-02-14'),
|
||||||
|
});
|
|
@ -2,6 +2,7 @@ import { tool as base64FileConverter } from './base64-file-converter';
|
||||||
import { tool as base64StringConverter } from './base64-string-converter';
|
import { tool as base64StringConverter } from './base64-string-converter';
|
||||||
import { tool as basicAuthGenerator } from './basic-auth-generator';
|
import { tool as basicAuthGenerator } from './basic-auth-generator';
|
||||||
import { tool as textToUnicode } from './text-to-unicode';
|
import { tool as textToUnicode } from './text-to-unicode';
|
||||||
|
import { tool as ed25519KeyPairGenerator } from './ed25519-key-pair-generator';
|
||||||
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
|
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
|
||||||
import { tool as numeronymGenerator } from './numeronym-generator';
|
import { tool as numeronymGenerator } from './numeronym-generator';
|
||||||
import { tool as macAddressGenerator } from './mac-address-generator';
|
import { tool as macAddressGenerator } from './mac-address-generator';
|
||||||
|
@ -81,7 +82,20 @@ import { tool as yamlViewer } from './yaml-viewer';
|
||||||
export const toolsByCategory: ToolCategory[] = [
|
export const toolsByCategory: ToolCategory[] = [
|
||||||
{
|
{
|
||||||
name: 'Crypto',
|
name: 'Crypto',
|
||||||
components: [tokenGenerator, hashText, bcrypt, uuidGenerator, ulidGenerator, cypher, bip39, hmacGenerator, rsaKeyPairGenerator, passwordStrengthAnalyser, pdfSignatureChecker],
|
components: [
|
||||||
|
tokenGenerator,
|
||||||
|
hashText,
|
||||||
|
bcrypt,
|
||||||
|
uuidGenerator,
|
||||||
|
ulidGenerator,
|
||||||
|
cypher,
|
||||||
|
bip39,
|
||||||
|
hmacGenerator,
|
||||||
|
rsaKeyPairGenerator,
|
||||||
|
ed25519KeyPairGenerator,
|
||||||
|
passwordStrengthAnalyser,
|
||||||
|
pdfSignatureChecker,
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Converter',
|
name: 'Converter',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue