The Password Generator builds complex passwords on demand.
It is a simple process that:
- gets the number of chacters to be used in the password
- gets the number of character sets to be used & flags them
- selects a random character from a character set chosen randomly from the set of flagged character sets
- appends the character to the end of the password
- displays the password in the textarea.
- Minimum Length: 8 characters
- Maximum Length: 128 Characters
- Passwords can contain:
- lower case characters
- upper case charcaters
- numbers
- special characters
- at least 1 character set must be used.
All data specific to generating the password has been placed in a JavaScript object named passwordSettings.
Changes to the password specifications (number of characters or minimum character sets) are made in the object. Generally there would be no need to change the code.
passwordSettings contains the following:
lowercase: ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",],
uppercase: ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",],
numbers: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
special: ["@", "%", "+", "\\", "/", "'", "!", "#", "$", "^", "?", ":", ",", ")", "(", "}", "{", "]", "[", "~", "-", "_", ".",],
options: ["lowercase", "uppercase", "numbers", "special"],
prompts: ["Lowercase Characters", "Uppercase Characters", "Numbers", "Special Characters"],
choices: [],
minimumLength: 8,
maximumLength: 128,
minimumCharacterSets: 1,
nextPasswordCharacter: function () {
// Get the next character set to be used from the array of selected character sets
characterSet = this.choices[Math.floor(Math.random() * this.choices.length)];
// Get the next Password Character
return this[characterSet][Math.floor(Math.random() * this[characterSet].length)
];
},
- lowercase, uppercase, numbers and special are arrays that hold the Character Sets that can be used.
- options holds names of the charcaters sets
- prompts holds message prompts to allow looping
- choices holds the charcater set choices entered at runtime
- minimumLength is the minimum password length
- maximumLength is the maximum password length
- minimumCharacterSets is the minimum number of character sets to be used in the password
- nextPasswordCharacter is a function that will generate the next character using the information stored in the object.
Click the link to visit the deployed wbsite: Password Generator.
The Password Generator is a landing page tha contains : 1: Header - containing a Heading 2: Main Content Area - containing a Text Area that will display the generated password. 3. A button that initiates the JS code to generate the password.
The Password Generator website looks like this:.
Clicking the Generate Password Button starts collecting paramters the website needs to generate a password.
If: 1. a valid password length is entered the process will continue. 2. cancel is clicked the proces will stop 3. OK (with an empty inout field) the process will stop 4. any other entry and the prompt will be presented again
If: 1. If OK is clicked then Lowercase Chacters will be included in password 2. If Cancel is clicked then Lowercase Characters will not be included in the password
If: 1. If OK is clicked then Uppercase Chacters will be included in password 2. If Cancel is clicked then Uppercase Characters will not be included in the password
If: 1. If OK is clicked then Numbers will be included in password 2. If Cancel is clicked then Numbers will not be included in the password
If: 1.If OK is clicked then Special Characters will be included in password 2. If Cancel is clicked then Special Characters will not be included in the password
If no Character Sets were chosen for the new password then this error message is displayed.
When OK is clicked the process to choose Caracter Sets for the password will be repeated.
When all necessary data has been entered the website will generate a new password and it will be displayed like this:
This a 25 character password using all Character Sets.
The development history is recorded in the Changelog.
- Bootcamp Materials - Lesson Material from Week 3
- Prior knowlege and experience
- MDM Web Docs working with objects
- MDM Web Docs loops and iteration
- Character Sets provided in class as Useful Resources