mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-24 06:40:20 +03:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
01a0e06c88 |
No files matched your search
Vendored
+1
-4
@@ -78,7 +78,6 @@ declare module '@vue/runtime-core' {
|
||||
Encryption: typeof import('./src/tools/encryption/encryption.vue')['default']
|
||||
EtaCalculator: typeof import('./src/tools/eta-calculator/eta-calculator.vue')['default']
|
||||
FavoriteButton: typeof import('./src/components/FavoriteButton.vue')['default']
|
||||
FileType: typeof import('./src/tools/file-type/file-type.vue')['default']
|
||||
FormatTransformer: typeof import('./src/components/FormatTransformer.vue')['default']
|
||||
GitMemo: typeof import('./src/tools/git-memo/git-memo.vue')['default']
|
||||
'GitMemo.content': typeof import('./src/tools/git-memo/git-memo.content.md')['default']
|
||||
@@ -136,19 +135,17 @@ declare module '@vue/runtime-core' {
|
||||
NH1: typeof import('naive-ui')['NH1']
|
||||
NH3: typeof import('naive-ui')['NH3']
|
||||
NIcon: typeof import('naive-ui')['NIcon']
|
||||
NInputNumber: typeof import('naive-ui')['NInputNumber']
|
||||
NLayout: typeof import('naive-ui')['NLayout']
|
||||
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
|
||||
NMenu: typeof import('naive-ui')['NMenu']
|
||||
NScrollbar: typeof import('naive-ui')['NScrollbar']
|
||||
NSpin: typeof import('naive-ui')['NSpin']
|
||||
NSwitch: typeof import('naive-ui')['NSwitch']
|
||||
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']
|
||||
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']
|
||||
|
||||
+1
-2
@@ -60,7 +60,6 @@
|
||||
"emojilib": "^3.0.10",
|
||||
"figlet": "^1.7.0",
|
||||
"figue": "^1.2.0",
|
||||
"file-type": "^19.0.0",
|
||||
"fuse.js": "^6.6.2",
|
||||
"highlight.js": "^11.7.0",
|
||||
"iarna-toml-esm": "^3.0.5",
|
||||
@@ -76,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",
|
||||
@@ -87,7 +87,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",
|
||||
|
||||
Generated
+94
-655
File diff suppressed because it is too large.
Load diff
@@ -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,76 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import type { FileTypeResult } from 'file-type';
|
||||
import { fileTypeFromBuffer } from 'file-type';
|
||||
import InputCopyable from '../../components/InputCopyable.vue';
|
||||
|
||||
const status = ref<'idle' | 'done' | 'error' | 'processing'>('idle');
|
||||
const file = ref<File | null>(null);
|
||||
const type = ref<FileTypeResult | undefined>(undefined);
|
||||
|
||||
async function onFileUploaded(uploadedFile: File) {
|
||||
file.value = uploadedFile;
|
||||
const fileBuffer = await uploadedFile.arrayBuffer();
|
||||
|
||||
status.value = 'processing';
|
||||
try {
|
||||
type.value = await fileTypeFromBuffer(new Uint8Array(fileBuffer.slice(0, 4096)));
|
||||
status.value = 'done';
|
||||
}
|
||||
catch (e) {
|
||||
status.value = 'error';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div style="flex: 0 0 100%" mb-3>
|
||||
<div mx-auto max-w-600px>
|
||||
<c-file-upload
|
||||
title="Drag and drop a file here, or click to select a file"
|
||||
@file-upload="onFileUploaded"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div mt-3 flex justify-center>
|
||||
<c-card v-if="status === 'done'" title="Information">
|
||||
<InputCopyable
|
||||
:value="file?.name || ''"
|
||||
label="File name:"
|
||||
label-position="left"
|
||||
label-width="100px"
|
||||
label-align="right"
|
||||
readonly
|
||||
mt-2
|
||||
/>
|
||||
|
||||
<InputCopyable
|
||||
:value="type?.ext || '<unknown>'"
|
||||
label="Extension:"
|
||||
label-position="left"
|
||||
label-width="100px"
|
||||
label-align="right"
|
||||
readonly
|
||||
mt-2
|
||||
/>
|
||||
<InputCopyable
|
||||
:value="type?.mime || '<unknown>'"
|
||||
label="MIME Type:"
|
||||
label-position="left"
|
||||
label-width="100px"
|
||||
label-align="right"
|
||||
readonly
|
||||
mt-2
|
||||
/>
|
||||
</c-card>
|
||||
<c-alert v-if="status === 'error'" type="error">
|
||||
An error occured processing {{ file?.name }}.
|
||||
</c-alert>
|
||||
<n-spin
|
||||
v-if="status === 'processing'"
|
||||
size="small"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,12 +0,0 @@
|
||||
import { File } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'File Type Detector',
|
||||
path: '/file-type',
|
||||
description: 'Identify the type of a file',
|
||||
keywords: ['file', 'type', 'identify', 'detector'],
|
||||
component: () => import('./file-type.vue'),
|
||||
icon: File,
|
||||
createdAt: new Date('2024-04-20'),
|
||||
});
|
||||
+15
-3
@@ -6,7 +6,7 @@ import { tool as asciiTextDrawer } from './ascii-text-drawer';
|
||||
|
||||
import { tool as textToUnicode } from './text-to-unicode';
|
||||
import { tool as safelinkDecoder } from './safelink-decoder';
|
||||
import { tool as fileType } from './file-type';
|
||||
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',
|
||||
@@ -149,7 +162,6 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
dockerRunToDockerComposeConverter,
|
||||
xmlFormatter,
|
||||
yamlViewer,
|
||||
fileType,
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -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'),
|
||||
});
|
||||
@@ -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>
|
||||
@@ -15,7 +15,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 ?? '/';
|
||||
|
||||
@@ -98,7 +97,6 @@ export default defineConfig({
|
||||
resolvers: [NaiveUiResolver(), IconsResolver({ prefix: 'icon' })],
|
||||
}),
|
||||
Unocss(),
|
||||
nodePolyfills(),
|
||||
],
|
||||
base: baseUrl,
|
||||
resolve: {
|
||||
|
||||
Reference in new issue
Block a user