function maskPassword(pwd) if(pwd.length <= 8) return '•'.repeat(pwd.length); return pwd.slice(0,4) + '••••••' + pwd.slice(-2);
function generatePassword() { let upper = "ABCDEFGHJKLMNPQRSTUVWXYZ"; let lower = "abcdefghijkmnopqrstuvwxyz"; let digits = "23456789"; let symbols = "!@#$%^&*()_+=-{}[]:;?/,.~"; let pool = ""; if(useUpper.checked) pool += upper; if(useLower.checked) pool += lower; if(useDigits.checked) pool += digits; if(useSymbols.checked) pool += symbols; if(pool === "") pool = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; let length = parseInt(lengthSlider.value); let pwd = ""; for(let i=0; i<length; i++) const rand = Math.floor(Math.random() * pool.length); pwd += pool[rand]; // ensure at least one char from each checked set (basic) let needsAdjust = false; if(useUpper.checked && !/[A-Z]/.test(pwd)) needsAdjust = true; if(useLower.checked && !/[a-z]/.test(pwd)) needsAdjust = true; if(useDigits.checked && !/[0-9]/.test(pwd)) needsAdjust = true; if(useSymbols.checked && !/[!@#$%^&*()_+=\-{}\[\]:;?\/,.~]/.test(pwd)) needsAdjust = true; if(needsAdjust && length>=4) { let pwdArr = pwd.split(''); if(useUpper.checked && !/[A-Z]/.test(pwd)) pwdArr[0] = upper[Math.floor(Math.random()*upper.length)]; if(useLower.checked && !/[a-z]/.test(pwd)) pwdArr[1] = lower[Math.floor(Math.random()*lower.length)]; if(useDigits.checked && !/[0-9]/.test(pwd)) pwdArr[2] = digits[Math.floor(Math.random()*digits.length)]; if(useSymbols.checked && !/[!@#$%^&*()_+=\-{}\[\]:;?\/,.~]/.test(pwd)) pwdArr[3] = symbols[Math.floor(Math.random()*symbols.length)]; pwd = pwdArr.join(''); } return pwd; } tyviania password
function saveVault(vault) localStorage.setItem(STORAGE_KEY, JSON.stringify(vault)); renderVault(); function maskPassword(pwd) if(pwd
<script> // -------- DOM elements ---------- const lengthSlider = document.getElementById('passLength'); const lenValue = document.getElementById('lenValue'); const useUpper = document.getElementById('useUpper'); const useLower = document.getElementById('useLower'); const useDigits = document.getElementById('useDigits'); const useSymbols = document.getElementById('useSymbols'); const generateBtn = document.getElementById('generateBtn'); const generatedPassDiv = document.getElementById('generatedPass'); const copyGenBtn = document.getElementById('copyGenBtn'); const serviceNameInput = document.getElementById('serviceName'); const saveToVaultBtn = document.getElementById('saveToVaultBtn'); const vaultBody = document.getElementById('vaultBody'); const searchVault = document.getElementById('searchVault'); const exportBtn = document.getElementById('exportVaultBtn'); const importBtn = document.getElementById('importVaultBtn'); const importFile = document.getElementById('importFile'); const clearAllBtn = document.getElementById('clearAllBtn'); function maskPassword(pwd) if(pwd.length <