Compare commits

..
Author SHA1 Message Date
sharevb 01a0e06c88 feat(new tool): PGP Encryption
Fix #451 and #945
2024-04-28 19:31:38 +02:00
sharevb 9eac9cb2a9 fix(integer base converter): support bigint (#872) 2024-04-22 08:45:51 +02:00
sharevb 23f82d956a fix(bcrypt tool): allow salt rounds up to 100 (#987)
* fix(bcrypt tool): allow salt rounds up to 100

Previously max salt rounds was 10

* chore(github workflows): ci and e2e tests: try updating to node 20
2024-04-15 09:43:12 +02:00
16 changed files with 279 additions and 747 deletions

No files matched your search

+1 -1
View File
@@ -15,7 +15,7 @@ jobs:
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: 'pnpm'
- name: Install dependencies
+1 -1
View File
@@ -18,7 +18,7 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: 'pnpm'
- name: Get Playwright version
+3 -1
View File
@@ -125,13 +125,13 @@ declare module '@vue/runtime-core' {
MenuIconItem: typeof import('./src/components/MenuIconItem.vue')['default']
MenuLayout: typeof import('./src/components/MenuLayout.vue')['default']
MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default']
MimeConverter: typeof import('./src/tools/mime-converter/mime-converter.vue')['default']
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
NCode: typeof import('naive-ui')['NCode']
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
NEllipsis: typeof import('naive-ui')['NEllipsis']
NFormItem: typeof import('naive-ui')['NFormItem']
NH1: typeof import('naive-ui')['NH1']
NH3: typeof import('naive-ui')['NH3']
NIcon: typeof import('naive-ui')['NIcon']
@@ -145,6 +145,7 @@ declare module '@vue/runtime-core' {
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']
PgpEncryption: typeof import('./src/tools/pgp-encryption/pgp-encryption.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']
@@ -153,6 +154,7 @@ 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']
+1 -3
View File
@@ -42,7 +42,6 @@
"@tiptap/starter-kit": "2.1.6",
"@tiptap/vue-3": "2.0.3",
"@types/figlet": "^1.5.8",
"@types/libmime": "^5.0.3",
"@vicons/material": "^0.12.0",
"@vicons/tabler": "^0.12.0",
"@vueuse/core": "^10.3.0",
@@ -67,7 +66,6 @@
"ibantools": "^4.3.3",
"json5": "^2.2.3",
"jwt-decode": "^3.1.2",
"libmime": "^5.3.4",
"libphonenumber-js": "^1.10.28",
"lodash": "^4.17.21",
"marked": "^10.0.0",
@@ -77,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",
@@ -133,7 +132,6 @@
"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",
+2 -2
View File
@@ -9,7 +9,7 @@ const useWebServer = process.env.NO_WEB_SERVER !== 'true';
*/
export default defineConfig({
testDir: './src',
testMatch: /.*\.e2e\.(spec\.)?ts/,
testMatch: /\.e2e\.(spec\.)?ts$/,
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
@@ -57,7 +57,7 @@ export default defineConfig({
&& {
webServer: {
command: 'npm run preview',
url: 'http://127.0.0.1:5050',
url: 'http://localhost:5050',
reuseExistingServer: !isCI,
},
}
+21 -649
View File
File diff suppressed because it is too large. Load diff
+20 -1
View File
@@ -1,6 +1,6 @@
import { type Ref, ref, watchEffect } from 'vue';
export { computedCatch };
export { computedCatch, computedCatchAsync };
function computedCatch<T, D>(getter: () => T, { defaultValue }: { defaultValue: D; defaultErrorMessage?: string }): [Ref<T | D>, Ref<string | undefined>];
function computedCatch<T, D>(getter: () => T, { defaultValue, defaultErrorMessage = 'Unknown error' }: { defaultValue?: D; defaultErrorMessage?: string } = {}) {
@@ -20,3 +20,22 @@ function computedCatch<T, D>(getter: () => T, { defaultValue, defaultErrorMessag
return [value, error] as const;
}
function computedCatchAsync<T, D>(getterAsync: () => Promise<T>, { defaultValue }: { defaultValue: D; defaultErrorMessage?: string }): [Ref<T | D>, Ref<string | undefined>];
function computedCatchAsync<T, D>(getterAsync: () => Promise<T>, { defaultValue, defaultErrorMessage = 'Unknown error' }: { defaultValue?: D; defaultErrorMessage?: string } = {}) {
const error = ref<string | undefined>();
const value = ref<T | D | undefined>();
watchEffect(async () => {
try {
error.value = undefined;
value.value = await getterAsync();
}
catch (err) {
error.value = err instanceof Error ? err.message : err?.toString() ?? defaultErrorMessage;
value.value = defaultValue;
}
});
return [value, error] as const;
}
+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="10" :min="0" w-full />
<n-input-number v-model:value="saltCount" placeholder="Salt rounds..." :max="100" :min="0" w-full />
</n-form-item>
<c-input-text :value="hashed" readonly text-center />
+15 -3
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 mimeConverter } from './mime-converter';
import { tool as safelinkDecoder } from './safelink-decoder';
import { tool as pgpEncryption } from './pgp-encryption';
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,
pgpEncryption,
],
},
{
name: 'Converter',
@@ -108,7 +121,6 @@ export const toolsByCategory: ToolCategory[] = [
listConverter,
tomlToJson,
tomlToYaml,
mimeConverter,
],
},
{
@@ -11,6 +11,9 @@ 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: number, digit: string, index: number) => {
.reduce((carry: bigint, digit: string, index: number) => {
if (!fromRange.includes(digit)) {
throw new Error(`Invalid digit "${digit}" for base ${fromBase}.`);
}
return (carry += fromRange.indexOf(digit) * fromBase ** index);
}, 0);
return (carry += BigInt(fromRange.indexOf(digit)) * BigInt(fromBase) ** BigInt(index));
}, 0n);
let newValue = '';
while (decValue > 0) {
newValue = toRange[decValue % toBase] + newValue;
decValue = (decValue - (decValue % toBase)) / toBase;
newValue = toRange[Number(decValue % BigInt(toBase))] + newValue;
decValue = (decValue - (decValue % BigInt(toBase))) / BigInt(toBase);
}
return newValue || '0';
}
-12
View File
@@ -1,12 +0,0 @@
import { Mail } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'MIME Encoding Converter',
path: '/mime-converter',
description: 'Convert from/to MIME Encoded-Word format (Mail Subject)',
keywords: ['mime', 'converter', 'subject', 'rfc2047', 'rfc1341', 'rfc2045'],
component: () => import('./mime-converter.vue'),
icon: Mail,
createdAt: new Date('2024-03-09'),
});
@@ -1,66 +0,0 @@
<script setup lang="ts">
import libmime from 'libmime';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
import { withDefaultOnError } from '@/utils/defaults';
const encodedInput = ref('');
const decodedOutput = computed(() => withDefaultOnError(() => libmime.decodeWords(encodedInput.value), '# invalid encoded value'));
const rawInput = ref('');
const encodedQOutput = computed(() => withDefaultOnError(() => libmime.encodeWord(rawInput.value, 'Q'), ''));
const encodedBOutput = computed(() => withDefaultOnError(() => libmime.encodeWord(rawInput.value, 'B'), ''));
</script>
<template>
<div style="max-width: 600px;">
<c-card title="Encode string in Encoded-Word format">
<c-input-text
v-model:value="rawInput"
multiline
placeholder="Put your string here..."
rows="5"
label="String to encode"
raw-text
mb-5
/>
<div>
<h3>Quotted Printable encoded string</h3>
<TextareaCopyable
:value="encodedQOutput"
placeholder="The Quotted Printable encoded version of your string will be here"
mb-5
/>
</div>
<div>
<h3>Base64 encoded string</h3>
<TextareaCopyable
:value="encodedBOutput"
placeholder="The Base64 encoded version of your string will be here"
mb-5
/>
</div>
</c-card>
<c-card title="Decode string in Encoded-Word format">
<c-input-text
v-model:value="encodedInput"
multiline
placeholder="Your encoded string..."
rows="5"
label="Encoded string to decode"
mb-5
/>
<div>
<h3>Decoded string</h3>
<TextareaCopyable
v-model:value="decodedOutput"
placeholder="The decoded string will be here"
mb-5
/>
</div>
</c-card>
</div>
</template>
+12
View File
@@ -0,0 +1,12 @@
import { Lock } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'PGP encryption',
path: '/pgp-encryption',
description: 'Encrypt and decrypt text clear text using PGP Keys.',
keywords: ['pgp', 'openpgp', 'encryption', 'cypher', 'encipher', 'crypt', 'decrypt'],
component: () => import('./pgp-encryption.vue'),
icon: Lock,
createdAt: new Date('2024-04-20'),
});
+194
View File
@@ -0,0 +1,194 @@
<script setup lang="ts">
import * as openpgp from 'openpgp';
import { computedCatchAsync } from '@/composable/computed/catchedComputed';
const cryptInput = ref('');
const cryptPublicKey = ref('');
const cryptPrivateKey = ref('');
const cryptPrivateKeyPassphrase = ref('');
const [cryptOutput, cryptError] = computedCatchAsync(async () => {
const publicKeyArmored = cryptPublicKey.value;
const privateKeyArmored = cryptPrivateKey.value;
const passphrase = cryptPrivateKeyPassphrase.value;
const text = cryptInput.value;
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
const privateKey = privateKeyArmored !== ''
? (passphrase !== ''
? await openpgp.decryptKey({
privateKey: await openpgp.readPrivateKey({ armoredKey: privateKeyArmored }),
passphrase,
})
: await openpgp.readPrivateKey({ armoredKey: privateKeyArmored }))
: undefined;
return await openpgp.encrypt({
message: await openpgp.createMessage({ text }),
encryptionKeys: publicKey,
signingKeys: privateKey,
});
}, {
defaultValue: '',
defaultErrorMessage: 'Unable to encrypt your text',
});
const decryptInput = ref('');
const decryptPublicKey = ref('');
const decryptPrivateKey = ref('');
const decryptPrivateKeyPassphrase = ref('');
const [decryptOutput, decryptError] = computedCatchAsync(async () => {
const publicKeyArmored = decryptPublicKey.value;
const privateKeyArmored = decryptPrivateKey.value;
const passphrase = decryptPrivateKeyPassphrase.value;
const encrypted = decryptInput.value;
const publicKey = publicKeyArmored !== '' ? await openpgp.readKey({ armoredKey: publicKeyArmored }) : undefined;
const privateKey = passphrase !== ''
? await openpgp.decryptKey({
privateKey: await openpgp.readPrivateKey({ armoredKey: privateKeyArmored }),
passphrase,
})
: await openpgp.readPrivateKey({ armoredKey: privateKeyArmored });
const message = await openpgp.readMessage({
armoredMessage: encrypted, // parse armored message
});
const { data: decrypted, signatures } = await openpgp.decrypt({
message,
verificationKeys: publicKey, // optional
decryptionKeys: privateKey,
});
if (signatures.length > 0) {
try {
await signatures[0].verified; // throws on invalid signature
}
catch (e: any) {
return {
decryptedText: decrypted,
signatureError: `Signature could not be verified: ${e.toString()}`,
};
}
}
return {
decryptedText: decrypted,
signatureError: '',
};
}, {
defaultValue: { decryptedText: '', signatureError: '' },
defaultErrorMessage: 'Unable to encrypt your text',
});
</script>
<template>
<div>
<c-card title="Encrypt">
<div>
<c-input-text
v-model:value="cryptInput"
label="Your text:"
placeholder="The string to encrypt"
rows="4"
multiline raw-text monospace autosize flex-1
/>
<div flex flex-1 flex-col gap-2>
<c-input-text
v-model:value="cryptPublicKey"
label="Target public key:"
placeholder="Target public key"
rows="5"
multiline raw-text monospace autosize flex-1
/>
<details>
<summary>Signing private key (optional)</summary>
<c-input-text
v-model:value="cryptPrivateKey"
label="Your private key:"
placeholder="The private key to use to sign message"
rows="5"
multiline raw-text monospace autosize flex-1
/>
<c-input-text
v-model:value="cryptPrivateKeyPassphrase"
label="Your private key password:" clearable raw-text
/>
</details>
</div>
</div>
<c-alert
v-if="cryptError && cryptPublicKey !== ''"
type="error" mt-12 title="Error while encrypting"
>
{{ cryptError }}
</c-alert>
<n-form-item label="Your text encrypted:" mt-3>
<TextareaCopyable
:value="cryptOutput || ''"
rows="3"
placeholder="Your string encrypted"
multiline monospace readonly autosize mt-5
/>
</n-form-item>
</c-card>
<c-card title="Decrypt">
<div>
<c-input-text
v-model:value="decryptInput"
label="Your PGP Message to decrypt:"
placeholder="The string to decrypt"
rows="4"
multiline raw-text monospace autosize flex-1
/>
<div flex flex-1 flex-col gap-2>
<c-input-text
v-model:value="decryptPrivateKey"
label="Your private key:"
placeholder="The private key to use to decrypt message"
rows="5"
multiline raw-text monospace autosize flex-1
/>
<c-input-text
v-model:value="decryptPrivateKeyPassphrase"
label="Your private key password:" clearable raw-text
/>
<details>
<summary>Signing public key (optional)</summary>
<c-input-text
v-model:value="decryptPublicKey"
label="Sender public key:"
placeholder="Sender public key"
rows="5"
multiline raw-text monospace autosize flex-1
/>
</details>
</div>
</div>
<c-alert v-if="decryptError && decryptPrivateKey !== ''" type="error" mt-3 title="Error while decrypting">
{{ decryptError }}
</c-alert>
<c-alert v-if="decryptOutput?.signatureError !== ''" type="error" mt-3 title="Signature verification">
{{ decryptOutput?.signatureError }}
</c-alert>
<n-form-item label="Your text decrypted:" mt-3>
<TextareaCopyable
:value="decryptOutput?.decryptedText || ''"
rows="3"
placeholder="Your string decrypted"
multiline monospace readonly autosize mt-5
/>
</n-form-item>
</c-card>
</div>
</template>
-2
View File
@@ -11,7 +11,6 @@ import Icons from 'unplugin-icons/vite';
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers';
import Components from 'unplugin-vue-components/vite';
import { defineConfig } from 'vite';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import { VitePWA } from 'vite-plugin-pwa';
import markdown from 'vite-plugin-vue-markdown';
import svgLoader from 'vite-svg-loader';
@@ -98,7 +97,6 @@ export default defineConfig({
resolvers: [NaiveUiResolver(), IconsResolver({ prefix: 'icon' })],
}),
Unocss(),
nodePolyfills(),
],
base: baseUrl,
resolve: {