Skip to content

Commit ecdf2c1

Browse files
committed
feat(new tool): Jasypt Encryption
Fix CorentinTh#1738
1 parent b776a40 commit ecdf2c1

5 files changed

Lines changed: 134 additions & 0 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@
208208
"is-ip": "^5.0.1",
209209
"isbn3": "^2.0.2",
210210
"iso-639-1": "^3.1.5",
211+
"jasypt": "^1.0.7",
211212
"javascript-obfuscator": "^5.1.0",
212213
"javastack.js": "^1.0.3",
213214
"jks-js": "^1.1.4",

pnpm-lock.yaml

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { ShieldOff } from '@vicons/tabler';
2+
import { defineTool } from '../tool';
3+
4+
export const tool = defineTool({
5+
name: 'Jasypt String Encryption',
6+
path: '/jasypt-string-encryption',
7+
description: 'Encrypt and decrypt strings using the Jasypt (Java Simplified Encryption) standard.',
8+
keywords: ['jasypt', 'java', 'spring', 'boot', 'string', 'encryption'],
9+
component: () => import('./jasypt-string-encryption.vue'),
10+
icon: ShieldOff,
11+
createdAt: new Date('2026-03-15'),
12+
category: 'Crypto',
13+
});
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<script setup lang="ts">
2+
import Jasypt from 'jasypt';
3+
4+
const mode = ref<'encrypt' | 'decrypt'>('encrypt');
5+
const password = ref('');
6+
const inputText = ref('');
7+
const outputRaw = ref('');
8+
const error = ref('');
9+
10+
const outputEncSyntax = computed(() =>
11+
outputRaw.value ? `ENC(${outputRaw.value})` : '',
12+
);
13+
14+
const isEncryptMode = computed(() => mode.value === 'encrypt');
15+
16+
function run() {
17+
error.value = '';
18+
try {
19+
const jasypt = new Jasypt();
20+
jasypt.setPassword(password.value);
21+
22+
if (isEncryptMode.value) {
23+
outputRaw.value = jasypt.encrypt(inputText.value);
24+
}
25+
else {
26+
outputRaw.value = jasypt.decrypt(inputText.value.trim().replace(/^ENC\(|\)$/g, ''));
27+
}
28+
}
29+
catch (err: any) {
30+
outputRaw.value = '';
31+
error.value = err.toString();
32+
}
33+
}
34+
</script>
35+
36+
<template>
37+
<div>
38+
<NForm label-placement="left" label-width="160px">
39+
<NFormItem label="Mode:">
40+
<NRadioGroup v-model:value="mode" size="small">
41+
<NRadioButton value="encrypt">
42+
Encrypt
43+
</NRadioButton>
44+
<NRadioButton value="decrypt">
45+
Decrypt
46+
</NRadioButton>
47+
</NRadioGroup>
48+
</NFormItem>
49+
50+
<NFormItem label="Password (Secret Key):">
51+
<NInput
52+
v-model:value="password"
53+
type="password"
54+
show-password-on="click"
55+
placeholder="Enter Jasypt password (salt / secret key)"
56+
/>
57+
</NFormItem>
58+
59+
<NFormItem :label="isEncryptMode ? 'Plain Text:' : 'Jasypt Encrypted String:'">
60+
<NInput
61+
v-model:value="inputText"
62+
type="textarea"
63+
rows="6"
64+
:placeholder="isEncryptMode
65+
? 'Text to encrypt (e.g. DB password)'
66+
: 'Encrypted value (e.g. ENC(...)) or raw Jasypt string'"
67+
/>
68+
</NFormItem>
69+
70+
<NSpace justify="center" mb-2>
71+
<NButton type="primary" :disabled="!password || !inputText" @click="run">
72+
{{ isEncryptMode ? 'Encrypt' : 'Decrypt' }}
73+
</NButton>
74+
</NSpace>
75+
76+
<c-alert v-if="error" mb-1>
77+
{{ error }}
78+
</c-alert>
79+
80+
<NCard v-if="outputRaw" title="Results">
81+
<input-copyable label="Decoded:" label-position="left" :value="outputRaw" mb-1 />
82+
<input-copyable v-if="isEncryptMode" label="Raw:" label-position="left" :value="outputRaw" mb-1 />
83+
<input-copyable v-if="isEncryptMode" label="ENC Form:" label-position="left" :value="outputEncSyntax" />
84+
</NCard>
85+
</NForm>
86+
</div>
87+
</template>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
declare module 'jasypt' {
2+
export default class Jasypt {
3+
constructor() {}
4+
setPassword(password: string): void
5+
encrypt(value: string): string
6+
decrypt(value: string): string
7+
}
8+
}

0 commit comments

Comments
 (0)