{"id":22884257,"url":"https://github.com/minusinfinite/password-generator","last_synced_at":"2025-10-24T14:40:57.815Z","repository":{"id":178015794,"uuid":"380387100","full_name":"minusInfinite/password-generator","owner":"minusInfinite","description":"BootCamp Homework 3 - Password generator","archived":false,"fork":false,"pushed_at":"2021-06-26T05:36:42.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-06T22:30:13.721Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/minusInfinite.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-26T01:14:07.000Z","updated_at":"2021-06-26T05:36:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"f9fca0cb-0047-4b12-834a-06f598b83486","html_url":"https://github.com/minusInfinite/password-generator","commit_stats":null,"previous_names":["minusinfinite/password-generator"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minusInfinite%2Fpassword-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minusInfinite%2Fpassword-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minusInfinite%2Fpassword-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minusInfinite%2Fpassword-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/minusInfinite","download_url":"https://codeload.github.com/minusInfinite/password-generator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246510291,"owners_count":20789314,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-13T19:17:04.736Z","updated_at":"2025-10-24T14:40:57.696Z","avatar_url":"https://github.com/minusInfinite.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Password Generator\n\n## Project Details\n\nFor week 3 the task was to complete the development of a password generator with the following User Story\n\nThe completed project can be found at - https://minusinfinite.github.io/password-generator/\n\n\u003e AS AN employee with access to sensitive data\n\u003e\n\u003e I WANT to randomly generate a password that meets certain criteria\n\u003e\n\u003e SO THAT I can create a strong password that provides greater security\n\nThe following starting point was provided.\n\n```javascript\n// Assignment Code\nvar generateBtn = document.querySelector(\"#generate\")\n\n// Write password to the #password input\nfunction writePassword() {\n    var password = generatePassword()\n    var passwordText = document.querySelector(\"#password\")\n\n    passwordText.value = password\n}\n\n// Add event listener to generate button\ngenerateBtn.addEventListener(\"click\", writePassword)\n```\n\n![Project Screenshot](/mdassets/project-template.png)\n\n## Acceptance Criteria and Examples\n\nThe project has the the following Acceptance Criteria and\n\n\u003e GIVEN I need a new, secure password\n\u003e\n\u003e WHEN I click the button to generate a password\n\u003e\n\u003e THEN I am presented with a series of prompts for password criteria\n\u003e\n\u003e WHEN prompted for password criteria\n\u003e\n\u003e THEN I select which criteria to include in the password\n\u003e\n\u003e WHEN prompted for the length of the password\n\u003e\n\u003e THEN I choose a length of at least 8 characters and no more than 128 characters\n\nUsing the Window Prompt, Alert and Confirm API the following sequence is demonstrated\n\n```javascript\nvar lengthPrompt = prompt(\"Enter a number between 8 and 128\")\nlengthPrompt = parseInt(lengthPrompt)\n\nif (isNaN(lengthPrompt) || lengthPrompt \u003c 8 || lengthPrompt \u003e 128) {\n    alert(\"Enter a valid number between 8 and 128\")\n    return (result = \"Error, try again\")\n} else {\n    //set the password length property\n    passwordProps.length = lengthPrompt\n}\n```\n\nThe above code is used to ask the user for a value between 8 and 128 characters.\nAs a prompt is a String, I've used the parseInt method to convert it to a number.\nIf it is not a number, less then 8 or greater than 128 and error alert and return is generated.\n\nIf the prompt is a validated it will be saved to an object for later use\n\n\u003e WHEN asked for character types to include in the password\n\u003e\n\u003e THEN I confirm whether or not to include lowercase, uppercase, numeric, and or special characters\n\u003e\n\u003e WHEN I answer each prompt\n\u003e\n\u003e THEN my input should be validated and at least one character type should be selected\n\nThis is demostrated in the following code.\n\n```javascript\nif (confirm(\"Include Lowercase Characters?\")) {\n    passwordProps.lowercase = true\n} else {\n    passwordProps.lowercase = false\n}\n\nif (confirm(\"Include Uppercase Characters?\")) {\n    passwordProps.uppercase = true\n} else {\n    passwordProps.uppercase = false\n}\n\nif (confirm(\"Include Numbers?\")) {\n    passwordProps.numbers = true\n} else {\n    passwordProps.numbers = false\n}\n\nif (confirm(\"Include Special Characters?\")) {\n    passwordProps.special = true\n} else {\n    passwordProps.special = false\n}\n\npasswordProps.includeChar()\n```\n\nThe above IF ELSE statements set the objects values and triggers the object method that will generate the required character list for the password.\n\n\u003e WHEN all prompts are answered\n\u003e\n\u003e THEN a password is generated that matches the selected criteria\n\nThe following code provides these requirements.\n\n```javascript\npasswordProps.includeChar()\n\nif (passwordProps.charList == \"\") {\n    alert(\"No Character types selected, press the button again\")\n    return (result = \"Error, try again\")\n} else {\n    for (var i = 0; i \u003c passwordProps.length; i++) {\n        result += passwordProps.charList.charAt(\n            Math.floor(Math.random() * (passwordProps.charList.length - 1))\n        )\n    }\n}\n\nreturn result\n```\n\nThis will check that at least one of the character type settings above has been confirmed.\nIf it has not an error is triggered. If at least one character type is confirmed a For loop will create the password required.\n\nAs commented in the code this was attempted from an answer found on Stack Overflow - https://stackoverflow.com/a/1349426\n\n\u003e WHEN the password is generated\n\u003e\n\u003e THEN the password is either displayed in an alert or written to the page\n\nBelow is an example of a generated password with a length of 12 and all character types selected.\n\n![Password Generation Complete](/mdassets/text-generated.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminusinfinite%2Fpassword-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fminusinfinite%2Fpassword-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminusinfinite%2Fpassword-generator/lists"}