How to save and find the "Prohibited passwords" list

I am working on a project where I need to have a set of password restrictions, which includes a file of forbidden passwords (all common passwords such as "abc", "abcdef", "12345", "password", etc.). The password file will consist of 10,000-15,000 words.

Now I want to make sure that when the user sets / changes the password, he does not exist in the list. I was thinking of using a dictionary (or map) in Java (with buckets like "A", "B", "C" .... "Z", "NUMBERS", "SPECIAL_CHARS"), so I just check the first character, and then search the appropriate bucket. But I'm not sure what performance I can get from this.

Any suggestions for working with the "Prohibited passwords" list. Any other pointers to watch out for?

+7
source share
3 answers

If you extend your approach to one column per row, you end up with a trie that looks like a good structure for this problem, although I see no reason not to use a single HashSet (in the end, the cost of checking is almost constant, and the hash set is looking for in the bucket where the password should be saved). Splitting a hash depending on the initial letter does not improve performance when compared with a single set.

On the other hand, if your implementation is limited by memory, you can avoid storing some forbidden passwords and conduct a rule-based check (for example, check if there are four consecutive characters that differ by one, as in "ghij", or check if they are fragments of a keyboard string, such as "yuiop"). Each rule will be equivalent to several forbidden passwords.

+2
source

You might want to use a real library for this. For example .. https://code.google.com/p/java-dictionary-password-validator/

+1
source

you need to write a method that can check the sequence of characters (Ex: abcdef) and the same characters (example: 111111) and all other restrictions. Along with this, any way you should accept a static List / Set variable that will contain all the bounded lines.

0
source

All Articles