MCPcopy Create free account
hub / github.com/codemistic/Web-Development / generatePassword

Function generatePassword

modern-password-generator/script.js:36–56  ·  view source on GitHub ↗
(lower, upper, number, symbol, length)

Source from the content-addressed store, hash-verified

34
35// Generate new password
36const generatePassword = (lower, upper, number, symbol, length) => {
37 let newPassword = "";
38 const typesCount = lower + upper + number + symbol;
39 const typesArr = [{ lower }, { upper }, { number }, { symbol }].filter(
40 (item) => Object.values(item)[0]
41 );
42
43 if (typesCount === 0 || length > 20) {
44 return "";
45 }
46
47 for (let i = 0; i < length; i += typesCount) {
48 typesArr.forEach((type) => {
49 const funcName = Object.keys(type)[0];
50 newPassword += randomFunc[funcName]();
51 });
52 }
53
54 const finalPassword = newPassword.slice(0, length);
55 return finalPassword;
56};
57
58// Copy password to clipboard
59copyToClipboardBtn.addEventListener("click", () => {

Callers 1

script.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected