mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-25 23:24:09 +03:00
Merge branch 'feat/ecdsa-keygen' into chore/all-my-stuffs
# Conflicts: # components.d.ts # package.json # pnpm-lock.yaml # src/tools/index.ts # vite.config.ts
This commit is contained in:
commit
8617af9a6b
5 files changed
+150
No files matched your search
@@ -99,6 +99,7 @@
|
|||||||
"@types/figlet": "^1.5.8",
|
"@types/figlet": "^1.5.8",
|
||||||
"@types/markdown-it": "^13.0.7",
|
"@types/markdown-it": "^13.0.7",
|
||||||
"@types/figlet": "^1.5.8",
|
"@types/figlet": "^1.5.8",
|
||||||
|
"@types/sshpk": "^1.17.4",
|
||||||
"@vicons/material": "^0.12.0",
|
"@vicons/material": "^0.12.0",
|
||||||
"@vicons/tabler": "^0.12.0",
|
"@vicons/tabler": "^0.12.0",
|
||||||
"@vueuse/core": "^10.11.1",
|
"@vueuse/core": "^10.11.1",
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import sshpk from 'sshpk';
|
||||||
|
|
||||||
|
export { generateKeyPair };
|
||||||
|
|
||||||
|
async function generateKeyPair(config: {
|
||||||
|
password?: string
|
||||||
|
format?: sshpk.PrivateKeyFormatType
|
||||||
|
curve?: sshpk.CurveType
|
||||||
|
comment?: string
|
||||||
|
} = {}) {
|
||||||
|
const privKey = sshpk.generatePrivateKey('ecdsa', {
|
||||||
|
curve: config?.curve,
|
||||||
|
});
|
||||||
|
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,100 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type sshpk from 'sshpk';
|
||||||
|
import { generateKeyPair } from './ecdsa-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 curve = useStorage('ecdsa-key-pair-generator:curve', 'nistp256');
|
||||||
|
const curveOptions = [
|
||||||
|
{ value: 'nistp256', label: 'nistp256' },
|
||||||
|
{ value: 'nistp384', label: 'nistp384' },
|
||||||
|
{ value: 'nistp521', label: 'nistp521' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const format = useStorage('ecdsa-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,
|
||||||
|
curve: curve.value as sshpk.CurveType,
|
||||||
|
comment: comment.value,
|
||||||
|
},
|
||||||
|
), emptyCerts),
|
||||||
|
emptyCerts,
|
||||||
|
);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div max-w-600px>
|
||||||
|
<n-space mb-1>
|
||||||
|
<c-select
|
||||||
|
v-model:value="format"
|
||||||
|
label-position="left"
|
||||||
|
label="Format:"
|
||||||
|
:options="formatOptions"
|
||||||
|
placeholder="Select a key format"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<c-select
|
||||||
|
v-model:value="curve"
|
||||||
|
label-position="left"
|
||||||
|
label="Curve:"
|
||||||
|
:options="curveOptions"
|
||||||
|
placeholder="Select a curve type"
|
||||||
|
/>
|
||||||
|
</n-space>
|
||||||
|
|
||||||
|
<div v-if="supportsPassphrase" mb-1 mt-3>
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<div mb-2>
|
||||||
|
<n-form-item label="Comment :" label-placement="left">
|
||||||
|
<n-input
|
||||||
|
v-model:value="comment"
|
||||||
|
type="text"
|
||||||
|
placeholder="Comment"
|
||||||
|
/>
|
||||||
|
</n-form-item>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<n-space justify="center" mb-1>
|
||||||
|
<c-button @click="refreshCerts">
|
||||||
|
Refresh key-pair
|
||||||
|
</c-button>
|
||||||
|
</n-space>
|
||||||
|
|
||||||
|
<n-divider />
|
||||||
|
|
||||||
|
<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: 'ECDSA key pair generator',
|
||||||
|
path: '/ecdsa-key-pair-generator',
|
||||||
|
description: 'Generate new random ECDSA private and public keys (with or without passphrase).',
|
||||||
|
keywords: ['ecdsa', 'key', 'pair', 'generator', 'public', 'private', 'secret', 'ssh', 'pem', 'passphrase', 'password'],
|
||||||
|
component: () => import('./ecdsa-key-pair-generator.vue'),
|
||||||
|
icon: Certificate,
|
||||||
|
createdAt: new Date('2024-04-20'),
|
||||||
|
});
|
||||||
@@ -109,6 +109,7 @@ import { tool as textToUnicode } from './text-to-unicode';
|
|||||||
import { tool as csrGenerator } from './csr-generator';
|
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 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';
|
||||||
@@ -240,6 +241,9 @@ export const toolsByCategory: ToolCategory[] = [
|
|||||||
csrGenerator,
|
csrGenerator,
|
||||||
passwordStrengthAnalyser,
|
passwordStrengthAnalyser,
|
||||||
pdfSignatureChecker,
|
pdfSignatureChecker,
|
||||||
|
passwordStrengthAnalyser,
|
||||||
|
pdfSignatureChecker,
|
||||||
|
ecdsaKeyPairGenerator,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user