feat(htpasswd generator): allow salt rounds input (if bcrypt)

This commit is contained in:
sharevb 2024-04-14 14:43:40 +02:00
parent 3a0b612239
commit 3b7b0a45e6

View file

@ -6,6 +6,7 @@ import TextareaCopyable from '@/components/TextareaCopyable.vue';
const username = ref(''); const username = ref('');
const password = ref(''); const password = ref('');
const hashMethod = ref('bcrypt'); const hashMethod = ref('bcrypt');
const saltCount = ref(10);
const htpasswd = computed(() => { const htpasswd = computed(() => {
if (username.value === '' || password.value === '') { if (username.value === '' || password.value === '') {
@ -16,7 +17,7 @@ const htpasswd = computed(() => {
hash = md5(password.value); hash = md5(password.value);
} }
else { else {
hash = hashSync(password.value, 10); hash = hashSync(password.value, saltCount.value);
} }
return `${username.value}:${hash}`; return `${username.value}:${hash}`;
}); });
@ -46,6 +47,10 @@ const htpasswd = computed(() => {
:options="['bcrypt', 'md5']" :options="['bcrypt', 'md5']"
/> />
<n-form-item v-if="hashMethod === 'bcrypt'" label="Salt count: " label-placement="left" label-width="120">
<n-input-number v-model:value="saltCount" placeholder="Salt rounds..." :max="100" :min="0" w-full />
</n-form-item>
<n-divider /> <n-divider />
<n-form-item label="htpasswd content:"> <n-form-item label="htpasswd content:">