mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-20 21:23:08 +03:00
feat(Passphrase Generator): add option to add number at end of some words
Fix https://github.com/CorentinTh/it-tools/discussions/1228#discussioncomment-12514695
This commit is contained in:
1 parent
dfe05ff5ac
commit
76c2804052
2 files changed
+43
-13
No files matched your search
Vendored
+7
-6
@@ -131,9 +131,11 @@ declare module '@vue/runtime-core' {
|
||||
'GitMemo.content': typeof import('./src/tools/git-memo/git-memo.content.md')['default']
|
||||
GptTokenEstimator: typeof import('./src/tools/gpt-token-estimator/gpt-token-estimator.vue')['default']
|
||||
GzipConverter: typeof import('./src/tools/gzip-converter/gzip-converter.vue')['default']
|
||||
HarSanitizer: typeof import('./src/tools/har-sanitizer/har-sanitizer.vue')['default']
|
||||
HashText: typeof import('./src/tools/hash-text/hash-text.vue')['default']
|
||||
HddCalculator: typeof import('./src/tools/hdd-calculator/hdd-calculator.vue')['default']
|
||||
HeicConverter: typeof import('./src/tools/heic-converter/heic-converter.vue')['default']
|
||||
HexConverter: typeof import('./src/tools/hex-converter/hex-converter.vue')['default']
|
||||
HexFileConverter: typeof import('./src/tools/hex-file-converter/hex-file-converter.vue')['default']
|
||||
HmacGenerator: typeof import('./src/tools/hmac-generator/hmac-generator.vue')['default']
|
||||
'Home.page': typeof import('./src/pages/Home.page.vue')['default']
|
||||
@@ -161,6 +163,8 @@ declare module '@vue/runtime-core' {
|
||||
IconMdiSearch: typeof import('~icons/mdi/search')['default']
|
||||
IconMdiTranslate: typeof import('~icons/mdi/translate')['default']
|
||||
IconMdiTriangleDown: typeof import('~icons/mdi/triangle-down')['default']
|
||||
IesLightingGuidelines: typeof import('./src/tools/ies-lighting-guidelines/ies-lighting-guidelines.vue')['default']
|
||||
IlluminanceConverter: typeof import('./src/tools/illuminance-converter/illuminance-converter.vue')['default']
|
||||
ImageConverter: typeof import('./src/tools/image-converter/image-converter.vue')['default']
|
||||
ImageExifReader: typeof import('./src/tools/image-exif-reader/image-exif-reader.vue')['default']
|
||||
ImageResizer: typeof import('./src/tools/image-resizer/image-resizer.vue')['default']
|
||||
@@ -246,13 +250,9 @@ declare module '@vue/runtime-core' {
|
||||
NanoMemo: typeof import('./src/tools/nano-memo/nano-memo.vue')['default']
|
||||
'NanoMemo.content': typeof import('./src/tools/nano-memo/nano-memo.content.md')['default']
|
||||
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
|
||||
NCheckbox: typeof import('naive-ui')['NCheckbox']
|
||||
NCode: typeof import('naive-ui')['NCode']
|
||||
NCode: typeof import('naive-ui')['NCode']
|
||||
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
|
||||
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
|
||||
NEllipsis: typeof import('naive-ui')['NEllipsis']
|
||||
NForm: typeof import('naive-ui')['NForm']
|
||||
NFormItem: typeof import('naive-ui')['NFormItem']
|
||||
NginxFormatter: typeof import('./src/tools/nginx-formatter/nginx-formatter.vue')['default']
|
||||
NH1: typeof import('naive-ui')['NH1']
|
||||
@@ -262,9 +262,9 @@ declare module '@vue/runtime-core' {
|
||||
NLayout: typeof import('naive-ui')['NLayout']
|
||||
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
|
||||
NMenu: typeof import('naive-ui')['NMenu']
|
||||
NScrollbar: typeof import('naive-ui')['NScrollbar']
|
||||
NScrollbar: typeof import('naive-ui')['NScrollbar']
|
||||
NSlider: typeof import('naive-ui')['NSlider']
|
||||
NSpace: typeof import('naive-ui')['NSpace']
|
||||
NSwitch: typeof import('naive-ui')['NSwitch']
|
||||
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
|
||||
OcrImage: typeof import('./src/tools/ocr-image/ocr-image.vue')['default']
|
||||
Option43Generator: typeof import('./src/tools/option43-generator/option43-generator.vue')['default']
|
||||
@@ -309,6 +309,7 @@ declare module '@vue/runtime-core' {
|
||||
RsaKeyPairGenerator: typeof import('./src/tools/rsa-key-pair-generator/rsa-key-pair-generator.vue')['default']
|
||||
SafelinkDecoder: typeof import('./src/tools/safelink-decoder/safelink-decoder.vue')['default']
|
||||
SensitiveDataMasker: typeof import('./src/tools/sensitive-data-masker/sensitive-data-masker.vue')['default']
|
||||
SharepointDecoder: typeof import('./src/tools/sharepoint-decoder/sharepoint-decoder.vue')['default']
|
||||
SipAuth: typeof import('./src/tools/sip-auth/sip-auth.vue')['default']
|
||||
SlaCalculator: typeof import('./src/tools/sla-calculator/sla-calculator.vue')['default']
|
||||
SlugifyString: typeof import('./src/tools/slugify-string/slugify-string.vue')['default']
|
||||
|
||||
@@ -3,20 +3,45 @@ import { generateSillyPassword } from 'silly-password-generator';
|
||||
import { useCopy } from '@/composable/copy';
|
||||
import { useQueryParamOrStorage } from '@/composable/queryParams';
|
||||
import { computedRefreshable } from '@/composable/computedRefreshable';
|
||||
import { randIntFromInterval } from '@/utils/random';
|
||||
|
||||
const count = useQueryParamOrStorage({ name: 'count', storageName: 'pass-generator:count', defaultValue: 1 });
|
||||
const words = useQueryParamOrStorage({ name: 'words', storageName: 'pass-generator:words', defaultValue: 5 });
|
||||
const numbers = useQueryParamOrStorage({ name: 'nums', storageName: 'pass-generator:nums', defaultValue: 0 });
|
||||
const capitalize = useQueryParamOrStorage({ name: 'capitalize', storageName: 'pass-generator:capitalize', defaultValue: false });
|
||||
const saltChars = useQueryParamOrStorage({ name: 'salt', storageName: 'pass-generator:salt', defaultValue: '' });
|
||||
const separator = useQueryParamOrStorage({ name: 'sep', storageName: 'pass-generator:sep', defaultValue: '-' });
|
||||
|
||||
const [passphrases, refreshPassphrases] = computedRefreshable(() =>
|
||||
Array.from({ length: count.value },
|
||||
() => generateSillyPassword({
|
||||
capitalize: capitalize.value,
|
||||
wordCount: words.value,
|
||||
salt: saltChars.value,
|
||||
}).replace(/\s+/g, separator.value)).join('\n'),
|
||||
const [passphrases, refreshPassphrases] = computedRefreshable(
|
||||
() => Array.from({ length: count.value },
|
||||
() => {
|
||||
const requiredNumbers = Math.min(words.value, numbers.value);
|
||||
const nums: number[] = [];
|
||||
if (words.value === requiredNumbers) {
|
||||
for (let i = 0; i < requiredNumbers; i++) {
|
||||
nums.push(i);
|
||||
}
|
||||
}
|
||||
else {
|
||||
while (nums.length < requiredNumbers) {
|
||||
const rndNumber = randIntFromInterval(0, words.value - 1);
|
||||
if (!nums.includes(rndNumber)) {
|
||||
nums.push(rndNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return generateSillyPassword({
|
||||
capitalize: capitalize.value,
|
||||
wordCount: words.value,
|
||||
salt: saltChars.value,
|
||||
}).split(/\s+/g).map((word, i) => {
|
||||
if (nums.includes(i)) {
|
||||
return word + randIntFromInterval(1, 100);
|
||||
}
|
||||
return word;
|
||||
}).join(separator.value);
|
||||
}).join('\n'),
|
||||
);
|
||||
|
||||
const { copy } = useCopy({ source: passphrases, text: 'Passphrase(s) copied to clipboard!' });
|
||||
@@ -29,6 +54,10 @@ const { copy } = useCopy({ source: passphrases, text: 'Passphrase(s) copied to c
|
||||
<n-slider v-model:value="words" :step="1" :min="1" :max="512" mr-2 />
|
||||
<n-input-number v-model:value="words" size="small" />
|
||||
</n-form-item>
|
||||
<n-form-item label="Add numbers after X words" label-placement="left">
|
||||
<n-slider v-model:value="numbers" :step="1" :min="1" :max="words" mr-2 />
|
||||
<n-input-number v-model:value="numbers" :max="words" size="small" />
|
||||
</n-form-item>
|
||||
|
||||
<n-space>
|
||||
<n-form-item label="Capitalize" label-placement="left">
|
||||
|
||||
Reference in new issue
Block a user