Skip to content

Commit d03b31e

Browse files
committed
Merge branch 'feat/htpasswd' into chore/all-my-stuffs
# Conflicts: # package.json # pnpm-lock.yaml # src/tools/index.ts
2 parents 8fed1bb + 9754453 commit d03b31e

File tree

5 files changed

+85
-1
lines changed

5 files changed

+85
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
"@xmldom/xmldom": "^0.8.10",
112112
"aircodes": "^1.3.16",
113113
"ansible-vault": "^1.1.1",
114+
"apache-md5": "^1.1.8",
114115
"bcryptjs": "^2.4.3",
115116
"big.js": "^6.2.2",
116117
"change-case": "^4.1.2",

pnpm-lock.yaml

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<script setup lang="ts">
2+
import { hashSync } from 'bcryptjs';
3+
import md5 from 'apache-md5';
4+
import TextareaCopyable from '@/components/TextareaCopyable.vue';
5+
6+
const username = ref('');
7+
const password = ref('');
8+
const hashMethod = ref('bcrypt');
9+
const saltCount = ref(10);
10+
11+
const htpasswd = computed(() => {
12+
if (username.value === '' || password.value === '') {
13+
return '# username and password must not be empty';
14+
}
15+
let hash;
16+
if (hashMethod.value === 'md5') {
17+
hash = md5(password.value);
18+
}
19+
else {
20+
hash = hashSync(password.value, saltCount.value);
21+
}
22+
return `${username.value}:${hash}`;
23+
});
24+
</script>
25+
26+
<template>
27+
<div>
28+
<c-input-text
29+
v-model:value="username"
30+
label="Username"
31+
placeholder="Your username..."
32+
clearable raw-text mb-5
33+
/>
34+
<c-input-text
35+
v-model:value="password"
36+
label="Password"
37+
placeholder="Your password..."
38+
clearable
39+
raw-text
40+
mb-2
41+
type="password"
42+
/>
43+
44+
<c-select
45+
v-model:value="hashMethod"
46+
label="Hash method:"
47+
:options="['bcrypt', 'md5']"
48+
/>
49+
50+
<n-form-item v-if="hashMethod === 'bcrypt'" label="Salt count: " label-placement="left" label-width="120">
51+
<n-input-number v-model:value="saltCount" placeholder="Salt rounds..." :max="100" :min="0" w-full />
52+
</n-form-item>
53+
54+
<n-divider />
55+
56+
<n-form-item label="htpasswd content:">
57+
<TextareaCopyable :value="htpasswd" />
58+
</n-form-item>
59+
</div>
60+
</template>

src/tools/htpasswd-generator/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { PasswordRound } from '@vicons/material';
2+
import { defineTool } from '../tool';
3+
4+
export const tool = defineTool({
5+
name: 'Htpasswd/htaccess generator',
6+
path: '/htpasswd-generator',
7+
description: 'htpassword/htaccess user/password generator',
8+
keywords: ['htpasswd', 'htaccess', 'bcrypt', 'password'],
9+
component: () => import('./htpasswd-generator.vue'),
10+
icon: PasswordRound,
11+
createdAt: new Date('2024-02-20'),
12+
});

src/tools/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ import { tool as ipGeoLocation } from './ip-geo-location';
7171
import { tool as ocrImage } from './ocr-image';
7272
import { tool as ansibleVaultCryptDecrypt } from './ansible-vault-crypt-decrypt';
7373
import { tool as gzipConverter } from './gzip-converter';
74+
import { tool as htpasswdGenerator } from './htpasswd-generator';
7475
import { tool as safelinkDecoder } from './safelink-decoder';
7576
import { tool as mongoObjectidConverter } from './mongo-objectid-converter';
7677
import { tool as removeExif } from './remove-exif';
@@ -304,6 +305,7 @@ export const toolsByCategory: ToolCategory[] = [
304305
urlParser,
305306
deviceInformation,
306307
basicAuthGenerator,
308+
htpasswdGenerator,
307309
metaTagGenerator,
308310
otpCodeGeneratorAndValidator,
309311
mimeTypes,

0 commit comments

Comments
 (0)