fix(Token Generator): multi token, last settings, length input, denied chars

Fix #777, #822 , #797, #466, #806, #1065
This commit is contained in:
sharevb 2024-03-03 09:44:53 +01:00 committed by ShareVB
parent a07806cd15
commit ff57fda388
5 changed files with 270 additions and 179 deletions

View file

@ -5,6 +5,7 @@ export function createToken({
withLowercase = true,
withNumbers = true,
withSymbols = false,
deniedChars = '',
length = 64,
alphabet,
}: {
@ -12,6 +13,7 @@ export function createToken({
withLowercase?: boolean
withNumbers?: boolean
withSymbols?: boolean
deniedChars?: string
length?: number
alphabet?: string
}) {
@ -20,7 +22,7 @@ export function createToken({
withLowercase ? 'abcdefghijklmopqrstuvwxyz' : '',
withNumbers ? '0123456789' : '',
withSymbols ? '.,;:!?./-"\'#{([-|\\@)]=}*+' : '',
].join(''); ;
].filter(c => !(deniedChars?.includes(c))).join(''); ;
return shuffleString(allAlphabet.repeat(length)).substring(0, length);
}