|
||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionRecently, one of my projects required a functionality where upon registering a new user in the system a password for the user had to be generated automatically. The requirement also dictated that the password generation process should support things like:
After a little bit of Googling, I came across a very good Password Generator. Unfortunately, this was written in PERL. Since my project was being developed using MS technologies (VB/ASP), I needed a solution using these technologies and that's when I ended up creating this JavaScript function. Script inputsThe script takes the following four input parameters:
All these parameters are optional. If no values are passed, the script uses the default values. In case of the maximum password length being greater than the pattern string length, the script automatically generates a new pattern string. Actually, this behavior can be altered such that it generates Pattern stringThe heart of this little script is the pattern string. This string basically contains the following:
If the pattern string is not specified the script auto generates one. For this, I have used the function genPattern(pintLen)
{
var strRet = "";
var iCntr = 0;
var rndNo = 0;
for (iCntr = 0; iCntr < pintLen; iCntr++)
{
rndNo = Math.floor((4 - 1 + 1) * Math.random() + 1)
switch (rndNo)
{
case 1:
strRet += "9";
break;
case 2:
strRet += "U";
break;
case 3:
strRet += "S";
break;
case 4:
strRet += "L";
break;
}
}
return strRet;
}
Password generationThe actual password is generated by calling the ConclusionOverall, this is a very simple script and compared to GeodSoft's password generator, offers limited options/flexibility. However it does satisfy the normal requirements. I checked the generated passwords with GeodSoft's Password Evaluator and found out that the password generated by this script is reasonably strong. Release history
|
|||||||||||||||||||||||||||||||||||||||||||||||