Password-generating - which non-alphanumeric symbols can I use? - Information Security Stack Exchange
c# - Password must have at least one non-alpha character - Stack Overflow
Need a quick opinion: is it okay to consider any non-alphanumeric character a special password character?
Most non-alphanumeric characters flagged as invalid in passwords and elsewhere | Netgate Forum
According to OWASP, which uses references from Microsoft AD, and Oracle Identity Manager, these symbols are allowed.
!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
https://www.owasp.org/index.php/Password_special_characters
However, I suppose that only answers your "usually" question. OWASP further explains that "Various operating systems and applications may apply limitations to this set".
Which to me says, it's completely subjective. Meaning, if I'm an application developer, I can choose to utilize industry standards (OWASP), or use my own subset.
So, to answer the "always" question, I think it would be safe to assume that these are acceptable.
!#$%&()+-/:;@[\]^_|~
Additionally, given the above information, I would go with these as the "sometimes forbidden" options.
"$%'()*+,-./:;<=>[]`{}
Since this is somewhat of a subjective question, no answer given can be 100% accurate. I think this should help with your task though..
If I were you, I would look at what other password generators use. For instance Bitwarden uses the first 8 shift characters of the top row of a US QWERTY keyboard: !@#$%^&*
This seems like a good compromise, especially if you want to be able to type the passwords yourself and you also want to be able to do so when using someone else's computer with a different keyboard layout. In fact in that case I might also leave out the $. For instance, @ and ! are available on every Latin keyboard layout that I know of, but { and } only appear on very few.
Use regex pattern ^(?=.{8})(?=.*[^a-zA-Z])
Explanation:
^(?=.{8})(?=.*[^a-zA-Z])
โโโโโฌโโโโโโโโโโโโฌโโโโโโโ
โ โ โ
โ โ โ string contains some non-letter character
โ โ
โ โ string contains at least 8 characters
โ
โ begining of line/string
If you want to limit also maximum length (let's say 16), then use regex pattern:
^(?=.{8,16}$)(?=.*[^a-zA-Z])
Run it through a fairly simple regex: [^a-zA-Z]
And then check it's length separately:
if(string.Length > 7)
We're working on password validation and stumbled on this issue. We could communicate to the user a set of special characters to check (e.g. !@#$) but I feel like any list would be too restrictive. Instead, just expecting a special character in the form of [^a-zA-Z0-9] would be more permissive.
Is my intuition correct here?