Answer the question
In order to leave comments, you need to log in
How to exclude Cyrillic input, special characters and spaces?
There is a TK:
Password Validation.
The password can contain only letters of the Latin alphabet (any case) and numbers. Cannot contain Cyrillic, special characters and spaces.
Examples:
QQwert12
- will pass validation
Кириллица123
- will not pass validation
But the problem is that it qweFrty123 йцу #
will also pass validation.
What should be the pattern / set for the expression that completely exclude Cyrillic, special characters and spaces?
Answer the question
In order to leave comments, you need to log in
[a-zA-Z0-9]+
But you have bad password requirements.
They betray the unprofessionalism of developers who implement such requirements.
This is a sign that the password is in an open (not hashed) form in the database.
This provokes making weak passwords.
It looks like a student handicraft.
If restrictions are introduced, then they are minimal:
- the password must not be empty. Everything.
However, warnings should be given if:
- the password contains Cyrillic, or any characters that are difficult to type on any arbitrary keyboard. The big problem is a password with unicode characters if you want to enter it on a smartphone. A big problem with Cyrillic if you want to log in from a computer in Turkey on vacation, losing, for example, your phone.
- the password is too short;
- the password hash is in the list of the most common passwords;
- the password looks like it was typed with inverted caps-lock.
These warnings should be visible, but should not prevent you from creating such a password. You can only discuss what concerns the list of the most common passwords, let's say the thousands of the most popular. Well, short (less than 6 characters).
The password should be hashed with the newly generated salt. You need to store the salt next to the hash. You can also specify the name of the hashing algorithm next to it. Right on the same line. This will not reduce security, but it will save you from the problems associated with switching to new hashing algorithms.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question