Compare commits

..
Author SHA1 Message Date
sharevb 97544530c9 Merge branch 'main' into feat/htpasswd 2024-04-14 20:28:32 +02:00
ShareVB 0de51a2dea chore(github workflows): ci and e2e tests: try updating to node 20 2024-04-14 20:27:30 +02:00
sharevb 3b7b0a45e6 feat(htpasswd generator): allow salt rounds input (if bcrypt) 2024-04-14 14:43:40 +02:00
sharevb 3a0b612239 feat(new tool): htpasswd generator
Fix #430 and #807
2024-02-25 14:19:09 +01:00
ShareVB e073b2babf chore: fix deps 2024-02-18 12:01:33 +01:00
sharevb 83832f3e2c feat(TextareaCopyable): word-wrap prop
Add word-wrap property (to allow presenting long public keys)
2024-02-18 11:39:13 +01:00
sharevb ee40ba1439 chore: prepare sshpk for cert/key/sshkeys related tools 2024-02-18 11:39:13 +01:00
sharevb 3f32990499 chore: prepare sshpk for cert/key/sshkeys related tools 2024-02-18 11:38:29 +01:00
15 changed files with 328 additions and 400 deletions

No files matched your search

+5 -4
View File
@@ -71,7 +71,6 @@ declare module '@vue/runtime-core' {
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']
DynamicValues: typeof import('./src/tools/benchmark-builder/dynamic-values.vue')['default']
EcdsaKeyPairGenerator: typeof import('./src/tools/ecdsa-key-pair-generator/ecdsa-key-pair-generator.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']
EmojiGrid: typeof import('./src/tools/emoji-picker/emoji-grid.vue')['default']
@@ -134,15 +133,18 @@ declare module '@vue/runtime-core' {
NDivider: typeof import('naive-ui')['NDivider']
NEllipsis: typeof import('naive-ui')['NEllipsis']
NFormItem: typeof import('naive-ui')['NFormItem']
NGi: typeof import('naive-ui')['NGi']
NGrid: typeof import('naive-ui')['NGrid']
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']
NLabel: typeof import('naive-ui')['NLabel']
NLayout: typeof import('naive-ui')['NLayout']
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
NMenu: typeof import('naive-ui')['NMenu']
NScrollbar: typeof import('naive-ui')['NScrollbar']
NSpace: typeof import('naive-ui')['NSpace']
NSpin: typeof import('naive-ui')['NSpin']
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']
@@ -157,7 +159,6 @@ declare module '@vue/runtime-core' {
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
RsaKeyPairGenerator: typeof import('./src/tools/rsa-key-pair-generator/rsa-key-pair-generator.vue')['default']
SafelinkDecoder: typeof import('./src/tools/safelink-decoder/safelink-decoder.vue')['default']
SlugifyString: typeof import('./src/tools/slugify-string/slugify-string.vue')['default']
SpanCopyable: typeof import('./src/components/SpanCopyable.vue')['default']
SqlPrettify: typeof import('./src/tools/sql-prettify/sql-prettify.vue')['default']
+3 -2
View File
@@ -42,12 +42,12 @@
"@tiptap/starter-kit": "2.1.6",
"@tiptap/vue-3": "2.0.3",
"@types/figlet": "^1.5.8",
"@types/sshpk": "^1.17.4",
"@vicons/material": "^0.12.0",
"@vicons/tabler": "^0.12.0",
"@vueuse/core": "^10.3.0",
"@vueuse/head": "^1.0.0",
"@vueuse/router": "^10.0.0",
"apache-md5": "^1.1.8",
"bcryptjs": "^2.4.3",
"change-case": "^4.1.2",
"colord": "^2.9.3",
@@ -88,7 +88,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",
@@ -113,6 +112,7 @@
"@types/node": "^18.15.11",
"@types/node-forge": "^1.3.2",
"@types/qrcode": "^1.5.0",
"@types/sshpk": "^1.17.4",
"@types/ua-parser-js": "^0.7.36",
"@types/uuid": "^9.0.0",
"@unocss/eslint-config": "^0.57.0",
@@ -134,6 +134,7 @@
"unplugin-icons": "^0.17.0",
"unplugin-vue-components": "^0.25.0",
"vite": "^4.4.9",
"vite-plugin-node-polyfills": "^0.21.0",
"vite-plugin-pwa": "^0.16.0",
"vite-plugin-vue-markdown": "^0.23.5",
"vite-svg-loader": "^4.0.0",
+235 -222
View File
File diff suppressed because it is too large. Load diff
+2 -1
View File
@@ -16,6 +16,7 @@ const props = withDefaults(
language?: string
copyPlacement?: 'top-right' | 'bottom-right' | 'outside' | 'none'
copyMessage?: string
wordWrap?: boolean
}>(),
{
followHeightOf: null,
@@ -47,7 +48,7 @@ const tooltipText = computed(() => isJustCopied.value ? 'Copied!' : copyMessage.
:style="height ? `min-height: ${height - 40 /* card padding */ + 10 /* negative margin compensation */}px` : ''"
>
<n-config-provider :hljs="hljs">
<n-code :code="value" :language="language" :trim="false" data-test-id="area-content" />
<n-code :code="value" :language="language" :word-wrap="wordWrap" :trim="false" data-test-id="area-content" />
</n-config-provider>
</n-scrollbar>
<div absolute right-10px top-10px>
+1 -1
View File
@@ -28,7 +28,7 @@ const compareMatch = computed(() => compareSync(compareString.value, compareHash
mb-2
/>
<n-form-item label="Salt count: " label-placement="left" label-width="120">
<n-input-number v-model:value="saltCount" placeholder="Salt rounds..." :max="100" :min="0" w-full />
<n-input-number v-model:value="saltCount" placeholder="Salt rounds..." :max="10" :min="0" w-full />
</n-form-item>
<c-input-text :value="hashed" readonly text-center />
@@ -1,33 +0,0 @@
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 }),
};
}
@@ -1,100 +0,0 @@
<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>
@@ -1,12 +0,0 @@
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'),
});
@@ -0,0 +1,60 @@
<script setup lang="ts">
import { hashSync } from 'bcryptjs';
import md5 from 'apache-md5';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
const username = ref('');
const password = ref('');
const hashMethod = ref('bcrypt');
const saltCount = ref(10);
const htpasswd = computed(() => {
if (username.value === '' || password.value === '') {
return '# username and password must not be empty';
}
let hash;
if (hashMethod.value === 'md5') {
hash = md5(password.value);
}
else {
hash = hashSync(password.value, saltCount.value);
}
return `${username.value}:${hash}`;
});
</script>
<template>
<div>
<c-input-text
v-model:value="username"
label="Username"
placeholder="Your username..."
clearable raw-text mb-5
/>
<c-input-text
v-model:value="password"
label="Password"
placeholder="Your password..."
clearable
raw-text
mb-2
type="password"
/>
<c-select
v-model:value="hashMethod"
label="Hash method:"
:options="['bcrypt', 'md5']"
/>
<n-form-item v-if="hashMethod === 'bcrypt'" label="Salt count: " label-placement="left" label-width="120">
<n-input-number v-model:value="saltCount" placeholder="Salt rounds..." :max="100" :min="0" w-full />
</n-form-item>
<n-divider />
<n-form-item label="htpasswd content:">
<TextareaCopyable :value="htpasswd" />
</n-form-item>
</div>
</template>
+12
View File
@@ -0,0 +1,12 @@
import { PasswordRound } from '@vicons/material';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Htpasswd/htaccess generator',
path: '/htpasswd-generator',
description: 'htpassword/htaccess user/password generator',
keywords: ['htpasswd', 'htaccess', 'bcrypt', 'password'],
component: () => import('./htpasswd-generator.vue'),
icon: PasswordRound,
createdAt: new Date('2024-02-20'),
});
+3 -15
View File
@@ -5,8 +5,8 @@ import { tool as basicAuthGenerator } from './basic-auth-generator';
import { tool as asciiTextDrawer } from './ascii-text-drawer';
import { tool as textToUnicode } from './text-to-unicode';
import { tool as htpasswdGenerator } from './htpasswd-generator';
import { tool as safelinkDecoder } from './safelink-decoder';
import { tool as ecdsaKeyPairGenerator } from './ecdsa-key-pair-generator';
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
import { tool as numeronymGenerator } from './numeronym-generator';
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -86,20 +86,7 @@ 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,
ecdsaKeyPairGenerator,
],
components: [tokenGenerator, hashText, bcrypt, uuidGenerator, ulidGenerator, cypher, bip39, hmacGenerator, rsaKeyPairGenerator, passwordStrengthAnalyser, pdfSignatureChecker],
},
{
name: 'Converter',
@@ -131,6 +118,7 @@ export const toolsByCategory: ToolCategory[] = [
urlParser,
deviceInformation,
basicAuthGenerator,
htpasswdGenerator,
metaTagGenerator,
otpCodeGeneratorAndValidator,
mimeTypes,
@@ -11,9 +11,6 @@ describe('integer-base-converter', () => {
expect(convertBase({ value: '10100101', fromBase: 2, toBase: 16 })).toEqual('a5');
expect(convertBase({ value: '192654', fromBase: 10, toBase: 8 })).toEqual('570216');
expect(convertBase({ value: 'zz', fromBase: 64, toBase: 10 })).toEqual('2275');
expect(convertBase({ value: '42540766411283223938465490632011909384', fromBase: 10, toBase: 10 })).toEqual('42540766411283223938465490632011909384');
expect(convertBase({ value: '42540766411283223938465490632011909384', fromBase: 10, toBase: 16 })).toEqual('20010db8000085a300000000ac1f8908');
expect(convertBase({ value: '20010db8000085a300000000ac1f8908', fromBase: 16, toBase: 10 })).toEqual('42540766411283223938465490632011909384');
});
});
});
@@ -5,16 +5,16 @@ export function convertBase({ value, fromBase, toBase }: { value: string; fromBa
let decValue = value
.split('')
.reverse()
.reduce((carry: bigint, digit: string, index: number) => {
.reduce((carry: number, digit: string, index: number) => {
if (!fromRange.includes(digit)) {
throw new Error(`Invalid digit "${digit}" for base ${fromBase}.`);
}
return (carry += BigInt(fromRange.indexOf(digit)) * BigInt(fromBase) ** BigInt(index));
}, 0n);
return (carry += fromRange.indexOf(digit) * fromBase ** index);
}, 0);
let newValue = '';
while (decValue > 0) {
newValue = toRange[Number(decValue % BigInt(toBase))] + newValue;
decValue = (decValue - (decValue % BigInt(toBase))) / BigInt(toBase);
newValue = toRange[decValue % toBase] + newValue;
decValue = (decValue - (decValue % toBase)) / toBase;
}
return newValue || '0';
}
+1 -1
View File
@@ -23,7 +23,7 @@ const decodeInput = ref('Hello%20world%20%3A)');
const decodeOutput = computed(() => withDefaultOnError(() => decodeURIComponent(decodeInput.value), ''));
const decodeValidation = useValidation({
source: decodeInput,
source: encodeInput,
rules: [
{
validator: value => isNotThrowing(() => decodeURIComponent(value)),
+1 -1
View File
@@ -1,5 +1,6 @@
import { resolve } from 'node:path';
import { URL, fileURLToPath } from 'node:url';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import VueI18n from '@intlify/unplugin-vue-i18n/vite';
import vue from '@vitejs/plugin-vue';
@@ -15,7 +16,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 ?? '/';