mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-04 21:37:11 -04:00
feat(htpasswd generator): allow salt rounds input (if bcrypt)
This commit is contained in:
parent
3a0b612239
commit
3b7b0a45e6
1 changed files with 6 additions and 1 deletions
|
@ -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:">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue