Author: | Riya-Panhotra |
---|---|
Views Total: | 557 views |
Official Page: | Go to website |
Last Update: | August 4, 2021 |
License: | MIT |
Preview:

Description:
An online app to generate random strong passwords with just one click. Written in HTML CSS & JavaScript. Without third-party libraries.
How to use it:
1. Create an input file to place the generated password strings.
<input type="text">
2. Create a button to generate a strong password.
<button>Generate Password</button>
3. Create Copy buttons inside the password field. Requires Font Awesome Iconic Font in this example.
<span class="far fa-copy" onclick="copy()"></span> <span class="fas fa-copy" onclick="copy()"></span>
4. The main script to enable the password generator.
const display = document.querySelector("input"), button = document.querySelector("button"), copyBtn = document.querySelector("span.far"), copyActive = document.querySelector("span.fas"); let chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+~`|}{[]:;?><,./-="; button.onclick = ()=>{ let i, randomPassword = ""; copyBtn.style.display = "block"; copyActive.style.display = "none"; for (i = 0; i < 16; i++) { randomPassword = randomPassword + chars.charAt( Math.floor(Math.random() * chars.length) ); } display.value = randomPassword; } function copy(){ copyBtn.style.display = "none"; copyActive.style.display = "block"; display.select(); document.execCommand("copy"); }