Skip to content

Commit 01a0e06

Browse files
committed
feat(new tool): PGP Encryption
Fix CorentinTh#451 and CorentinTh#945
1 parent 9eac9cb commit 01a0e06

File tree

7 files changed

+278
-15
lines changed

7 files changed

+278
-15
lines changed

components.d.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,27 +130,22 @@ declare module '@vue/runtime-core' {
130130
NCode: typeof import('naive-ui')['NCode']
131131
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
132132
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
133-
NDivider: typeof import('naive-ui')['NDivider']
134133
NEllipsis: typeof import('naive-ui')['NEllipsis']
135134
NFormItem: typeof import('naive-ui')['NFormItem']
136-
NGi: typeof import('naive-ui')['NGi']
137-
NGrid: typeof import('naive-ui')['NGrid']
138135
NH1: typeof import('naive-ui')['NH1']
139136
NH3: typeof import('naive-ui')['NH3']
140137
NIcon: typeof import('naive-ui')['NIcon']
141-
NInputNumber: typeof import('naive-ui')['NInputNumber']
142-
NLabel: typeof import('naive-ui')['NLabel']
143138
NLayout: typeof import('naive-ui')['NLayout']
144139
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
145140
NMenu: typeof import('naive-ui')['NMenu']
146141
NScrollbar: typeof import('naive-ui')['NScrollbar']
147-
NSpin: typeof import('naive-ui')['NSpin']
148142
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
149143
OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default']
150144
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']
151145
PdfSignatureChecker: typeof import('./src/tools/pdf-signature-checker/pdf-signature-checker.vue')['default']
152146
PdfSignatureDetails: typeof import('./src/tools/pdf-signature-checker/components/pdf-signature-details.vue')['default']
153147
PercentageCalculator: typeof import('./src/tools/percentage-calculator/percentage-calculator.vue')['default']
148+
PgpEncryption: typeof import('./src/tools/pgp-encryption/pgp-encryption.vue')['default']
154149
PhoneParserAndFormatter: typeof import('./src/tools/phone-parser-and-formatter/phone-parser-and-formatter.vue')['default']
155150
QrCodeGenerator: typeof import('./src/tools/qr-code-generator/qr-code-generator.vue')['default']
156151
RandomPortGenerator: typeof import('./src/tools/random-port-generator/random-port-generator.vue')['default']
@@ -159,6 +154,7 @@ declare module '@vue/runtime-core' {
159154
RouterLink: typeof import('vue-router')['RouterLink']
160155
RouterView: typeof import('vue-router')['RouterView']
161156
RsaKeyPairGenerator: typeof import('./src/tools/rsa-key-pair-generator/rsa-key-pair-generator.vue')['default']
157+
SafelinkDecoder: typeof import('./src/tools/safelink-decoder/safelink-decoder.vue')['default']
162158
SlugifyString: typeof import('./src/tools/slugify-string/slugify-string.vue')['default']
163159
SpanCopyable: typeof import('./src/components/SpanCopyable.vue')['default']
164160
SqlPrettify: typeof import('./src/tools/sql-prettify/sql-prettify.vue')['default']

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"naive-ui": "^2.35.0",
7676
"netmask": "^2.0.2",
7777
"node-forge": "^1.3.1",
78+
"openpgp": "^5.11.1",
7879
"oui-data": "^1.0.10",
7980
"pdf-signature-reader": "^1.4.2",
8081
"pinia": "^2.0.34",

pnpm-lock.yaml

Lines changed: 34 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/composable/computed/catchedComputed.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { type Ref, ref, watchEffect } from 'vue';
22

3-
export { computedCatch };
3+
export { computedCatch, computedCatchAsync };
44

55
function computedCatch<T, D>(getter: () => T, { defaultValue }: { defaultValue: D; defaultErrorMessage?: string }): [Ref<T | D>, Ref<string | undefined>];
66
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
2020

2121
return [value, error] as const;
2222
}
23+
24+
function computedCatchAsync<T, D>(getterAsync: () => Promise<T>, { defaultValue }: { defaultValue: D; defaultErrorMessage?: string }): [Ref<T | D>, Ref<string | undefined>];
25+
function computedCatchAsync<T, D>(getterAsync: () => Promise<T>, { defaultValue, defaultErrorMessage = 'Unknown error' }: { defaultValue?: D; defaultErrorMessage?: string } = {}) {
26+
const error = ref<string | undefined>();
27+
const value = ref<T | D | undefined>();
28+
29+
watchEffect(async () => {
30+
try {
31+
error.value = undefined;
32+
value.value = await getterAsync();
33+
}
34+
catch (err) {
35+
error.value = err instanceof Error ? err.message : err?.toString() ?? defaultErrorMessage;
36+
value.value = defaultValue;
37+
}
38+
});
39+
40+
return [value, error] as const;
41+
}

src/tools/index.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { tool as asciiTextDrawer } from './ascii-text-drawer';
66

77
import { tool as textToUnicode } from './text-to-unicode';
88
import { tool as safelinkDecoder } from './safelink-decoder';
9+
import { tool as pgpEncryption } from './pgp-encryption';
910
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
1011
import { tool as numeronymGenerator } from './numeronym-generator';
1112
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -85,7 +86,20 @@ import { tool as yamlViewer } from './yaml-viewer';
8586
export const toolsByCategory: ToolCategory[] = [
8687
{
8788
name: 'Crypto',
88-
components: [tokenGenerator, hashText, bcrypt, uuidGenerator, ulidGenerator, cypher, bip39, hmacGenerator, rsaKeyPairGenerator, passwordStrengthAnalyser, pdfSignatureChecker],
89+
components: [
90+
tokenGenerator,
91+
hashText,
92+
bcrypt,
93+
uuidGenerator,
94+
ulidGenerator,
95+
cypher,
96+
bip39,
97+
hmacGenerator,
98+
rsaKeyPairGenerator,
99+
passwordStrengthAnalyser,
100+
pdfSignatureChecker,
101+
pgpEncryption,
102+
],
89103
},
90104
{
91105
name: 'Converter',

src/tools/pgp-encryption/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Lock } from '@vicons/tabler';
2+
import { defineTool } from '../tool';
3+
4+
export const tool = defineTool({
5+
name: 'PGP encryption',
6+
path: '/pgp-encryption',
7+
description: 'Encrypt and decrypt text clear text using PGP Keys.',
8+
keywords: ['pgp', 'openpgp', 'encryption', 'cypher', 'encipher', 'crypt', 'decrypt'],
9+
component: () => import('./pgp-encryption.vue'),
10+
icon: Lock,
11+
createdAt: new Date('2024-04-20'),
12+
});

0 commit comments

Comments
 (0)