Here's an example function that generates a password with at least one symbol:
index.ts295 chars12 linesThis function takes a desired length for the password as an argument and generates a random password containing only symbols from the symbols string. The while loop keeps adding symbols to the password until it reaches the desired length.
You can adjust the symbols string to include any symbols you want to allow in the password.
If you want to ensure that the password also includes letters and numbers, you can modify the function to generate a mixed password like this:
index.ts864 chars31 linesThis function uses three separate sets of characters (symbols, letters, and numbers) to ensure that the password contains at least one of each type. The while loop then adds random characters from any of the three sets until the password reaches the desired length. The shuffleString function shuffles the order of the characters in the final password for added security.
gistlibby LogSnag