mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-22 22:02:38 +03:00
Merge branch 'feat/ed25519-keygen' into chore/all-my-stuffs
# Conflicts: # components.d.ts # package.json # pnpm-lock.yaml # src/tools/index.ts
This commit is contained in:
commit
365fb4b5bb
4 files changed
+126
No files matched your search
@@ -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>
|
||||||
@@ -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'),
|
||||||
|
});
|
||||||
@@ -110,6 +110,7 @@ import { tool as csrGenerator } from './csr-generator';
|
|||||||
import { tool as dockerRunToKubernetesConverter } from './docker-run-to-kubernetes';
|
import { tool as dockerRunToKubernetesConverter } from './docker-run-to-kubernetes';
|
||||||
import { tool as dockerComposeValidator } from './docker-compose-validator';
|
import { tool as dockerComposeValidator } from './docker-compose-validator';
|
||||||
import { tool as ecdsaKeyPairGenerator } from './ecdsa-key-pair-generator';
|
import { tool as ecdsaKeyPairGenerator } from './ecdsa-key-pair-generator';
|
||||||
|
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';
|
||||||
@@ -244,6 +245,9 @@ export const toolsByCategory: ToolCategory[] = [
|
|||||||
passwordStrengthAnalyser,
|
passwordStrengthAnalyser,
|
||||||
pdfSignatureChecker,
|
pdfSignatureChecker,
|
||||||
ecdsaKeyPairGenerator,
|
ecdsaKeyPairGenerator,
|
||||||
|
ed25519KeyPairGenerator,
|
||||||
|
passwordStrengthAnalyser,
|
||||||
|
pdfSignatureChecker,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user