Skip to content

Commit 3b7b0a4

Browse files
committed
feat(htpasswd generator): allow salt rounds input (if bcrypt)
1 parent 3a0b612 commit 3b7b0a4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/tools/htpasswd-generator/htpasswd-generator.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import TextareaCopyable from '@/components/TextareaCopyable.vue';
66
const username = ref('');
77
const password = ref('');
88
const hashMethod = ref('bcrypt');
9+
const saltCount = ref(10);
910
1011
const htpasswd = computed(() => {
1112
if (username.value === '' || password.value === '') {
@@ -16,7 +17,7 @@ const htpasswd = computed(() => {
1617
hash = md5(password.value);
1718
}
1819
else {
19-
hash = hashSync(password.value, 10);
20+
hash = hashSync(password.value, saltCount.value);
2021
}
2122
return `${username.value}:${hash}`;
2223
});
@@ -46,6 +47,10 @@ const htpasswd = computed(() => {
4647
:options="['bcrypt', 'md5']"
4748
/>
4849

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+
4954
<n-divider />
5055

5156
<n-form-item label="htpasswd content:">

0 commit comments

Comments
 (0)