Last post Aug 06, 2015 03:23 PM by gerrylowry
Aug 06, 2015 06:34 AM|Shibly|LINK
I want to create a password generator method which fulfill some validation rules. I already create a generator calling random object I but I don't understand how fulfill the validation rules. Here is my validation rules:
1. Minimal 1 upper and 1 lower case character
2. Minimal 1 digit in password
3. Minimal 1 punctuation mark in a password (!@#$%^&*()-_+=)
4. Not more than twice using the same character after each other
5. Same character must not exist more than 3 times in password
6. Minimal length must be 10 characters
can anyone help me please to build this password generator method using this validation rules.
Thanks in advance.
Aug 06, 2015 08:36 AM|Rion Williams|LINK
A naive approach to handling this might be to simply define all of your requirements as types of Regular Expressions and continually build a random string until it meets all of the requirements (at the end of each iteration, determining which requirements
are lacking and adding those). However, you may want to consider checking if this has already been done for you.
I came across
this project on GitHub, which appears to be designed to do exactly what you are looking for (generating strings based on certain rules). It appears to be quite well documented and it should be able to handle most of what you need.
Aug 06, 2015 03:23 PM|gerryLowry|LINK
KeePass has already done this for you; it's open source: http://keepass.info/
"KeePass, the free, open source, light-weight and easy-to-use password manager."
http://keepass.info/download.html "Source code packages, containing everything you need to build your own KeePass.exe and plugins (source code, resources, build
scripts, ...)" can be found near the bottom of the download page.
You can read about the password options here: http://keepass.info/help/base/pwgenerator.html