Password Generator





100% Secure Password Generator


Create your own password or auto-generate a secure one. Check strength live below!



















0%




How to Use:



  1. Type your own password in the top field — or click Generate for a secure one.

  2. Strength bar updates instantly while typing.

  3. Copy with the Copy button.

  4. Clear both fields anytime.


Password Generator

Pro Tips:



  • Use 12+ characters for optimal security.

  • Mix uppercase, lowercase, numbers, and symbols.

  • Use a password manager to safely store your passwords.



copyright>// const lower = "abcdefghijklmnopqrstuvwxyz";
const upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const numbers = "0123456789";
const symbols = "!@#$%^&*()-_=+[{]};:,.<>?";

const autoPwd = document.getElementById("autoPwd");
const customPwd = document.getElementById("customPwd");
const generateBtn = document.getElementById("generate");
const copyBtn = document.getElementById("copyPwd");
const toggleBtn = document.getElementById("togglePwd");
const clearBtn = document.getElementById("clearFields");
const bars = document.querySelectorAll(".barSeg");
const meterText = document.getElementById("meterText");

function randomChar(str) {
return str[Math.floor(Math.random() * str.length)];
}

function generatePassword() {
let charset = lower + upper + numbers + symbols;
let pwd = "";
for (let i = 0; i < 20; i++) { pwd += randomChar(charset); } autoPwd.value = pwd; checkStrength(pwd); } function checkStrength(pwd) { let score = 0; if (pwd.length >= 8) score++;
if (/[A-Z]/.test(pwd)) score++;
if (/[0-9]/.test(pwd)) score++;
if (/[^A-Za-z0-9]/.test(pwd)) score++;
if (pwd.length >= 16) score++;

bars.forEach((bar, index) => {
bar.style.background = index < score ? gradientColor(score) : "#e9ecef"; }); meterText.textContent = (score * 20) + "%"; } function gradientColor(score) { const colors = ["#dc3545", "#fd7e14", "#ffc107", "#17a2b8", "#28a745"]; return colors[score - 1]; } generateBtn.addEventListener("click", generatePassword); customPwd.addEventListener("input", () => checkStrength(customPwd.value));

copyBtn.addEventListener("click", () => {
let text = autoPwd.value || customPwd.value;
if (!text) return alert("No password to copy.");
navigator.clipboard.writeText(text);
alert("Password copied!");
});

toggleBtn.addEventListener("click", () => {
customPwd.type = customPwd.type === "password" ? "text" : "password";
autoPwd.type = autoPwd.type === "password" ? "text" : "password";
toggleBtn.textContent = customPwd.type === "password" ? "Show" : "Hide";
});

clearBtn.addEventListener("click", () => {
customPwd.value = "";
autoPwd.value = "";
checkStrength("");
});
// ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *