Skip to content

Commit 76f03ff

Browse files
committed
Merge branch 'feat/ansible-vault' into chore/all-my-stuffs
# Conflicts: # package.json # pnpm-lock.yaml # src/tools/index.ts
2 parents 2a985b6 + 8641d12 commit 76f03ff

File tree

5 files changed

+128
-1
lines changed

5 files changed

+128
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
"arr-diff": "^4.0.0",
106106
"@xmldom/xmldom": "^0.8.10",
107107
"aircodes": "^1.3.16",
108+
"ansible-vault": "^1.1.1",
108109
"bcryptjs": "^2.4.3",
109110
"big.js": "^6.2.2",
110111
"change-case": "^4.1.2",

pnpm-lock.yaml

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<script setup lang="ts">
2+
import { Vault } from 'ansible-vault';
3+
import TextareaCopyable from '@/components/TextareaCopyable.vue';
4+
5+
const decryptedInput = ref('');
6+
const encryptPassword = ref('');
7+
const encryptId = ref('');
8+
const cryptedOutput = computedAsync(
9+
async () => {
10+
try {
11+
const v = new Vault({ password: encryptPassword.value });
12+
return await v.encrypt(decryptedInput.value, encryptId.value);
13+
}
14+
catch (e: any) {
15+
return e.toString();
16+
}
17+
},
18+
);
19+
20+
const cryptedInput = ref('');
21+
const decryptPassword = ref('');
22+
const decryptedOutput = computedAsync(
23+
async () => {
24+
try {
25+
const v = new Vault({ password: decryptPassword.value });
26+
// handle mac \r
27+
return (await v.decrypt(cryptedInput.value?.replace(/\r(?!\n)/, '\n'), undefined)) ?? '';
28+
}
29+
catch (e: any) {
30+
return e.toString();
31+
}
32+
},
33+
);
34+
</script>
35+
36+
<template>
37+
<c-card title="Encrypt Ansible Vault Secret">
38+
<c-input-text
39+
v-model:value="decryptedInput"
40+
placeholder="Put your string to encrypt..."
41+
label="String to encrypt"
42+
raw-text
43+
mb-5
44+
/>
45+
46+
<n-space>
47+
<c-input-text
48+
v-model:value="encryptPassword"
49+
placeholder="Encryption password"
50+
label="Encryption password"
51+
raw-text
52+
mb-5
53+
/>
54+
<c-input-text
55+
v-model:value="encryptId"
56+
placeholder="Encryption Id"
57+
label="Encryption Id"
58+
raw-text
59+
mb-5
60+
/>
61+
</n-space>
62+
63+
<n-divider />
64+
65+
<TextareaCopyable
66+
label="Encrypted string"
67+
:value="cryptedOutput"
68+
multiline
69+
readonly
70+
rows="5"
71+
mb-5
72+
/>
73+
</c-card>
74+
75+
<c-card title="Decrypt Ansible Vault Secret">
76+
<c-input-text
77+
v-model:value="cryptedInput"
78+
placeholder="Put your encrypted string here..."
79+
label="String to decrypt"
80+
raw-text multiline mb-5
81+
rows="5"
82+
/>
83+
84+
<c-input-text
85+
v-model:value="decryptPassword"
86+
placeholder="Decryption password"
87+
label="Decryption password"
88+
raw-text
89+
mb-5
90+
/>
91+
92+
<n-divider />
93+
94+
<TextareaCopyable
95+
label="Decrypted string"
96+
:value="decryptedOutput"
97+
multiline
98+
readonly
99+
rows="5"
100+
mb-5
101+
/>
102+
</c-card>
103+
</template>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { LockSquare } from '@vicons/tabler';
2+
import { defineTool } from '../tool';
3+
4+
export const tool = defineTool({
5+
name: 'Ansible vault crypt decrypt',
6+
path: '/ansible-vault-crypt-decrypt',
7+
description: 'Encrypt and decrypt Ansible Vault Secrets',
8+
keywords: ['ansible', 'vault', 'crypt', 'decrypt'],
9+
component: () => import('./ansible-vault-crypt-decrypt.vue'),
10+
icon: LockSquare,
11+
createdAt: new Date('2024-02-25'),
12+
});

src/tools/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import { tool as certificateKeyParser } from './certificate-key-parser';
6767
import { tool as crcCalculator } from './crc-calculator';
6868
import { tool as ipGeoLocation } from './ip-geo-location';
6969
import { tool as ocrImage } from './ocr-image';
70+
import { tool as ansibleVaultCryptDecrypt } from './ansible-vault-crypt-decrypt';
7071
import { tool as safelinkDecoder } from './safelink-decoder';
7172
import { tool as mongoObjectidConverter } from './mongo-objectid-converter';
7273
import { tool as removeExif } from './remove-exif';
@@ -226,6 +227,9 @@ export const toolsByCategory: ToolCategory[] = [
226227
passwordStrengthAnalyser,
227228
pdfSignatureChecker,
228229
wpaPskGenerator,
230+
ansibleVaultCryptDecrypt,
231+
passwordStrengthAnalyser,
232+
pdfSignatureChecker,
229233
],
230234
},
231235
{

0 commit comments

Comments
 (0)