1function generatePassword(passwordLength) {
2 var numberChars = "0123456789";
3 var upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
4 var lowerChars = "abcdefghijklmnopqrstuvwxyz";
5 var allChars = numberChars + upperChars + lowerChars;
6 var randPasswordArray = Array(passwordLength);
7 randPasswordArray[0] = numberChars;
8 randPasswordArray[1] = upperChars;
9 randPasswordArray[2] = lowerChars;
10 randPasswordArray = randPasswordArray.fill(allChars, 3);
11 return shuffleArray(randPasswordArray.map(function(x) { return x[Math.floor(Math.random() * x.length)] })).join('');
12}
13
14function shuffleArray(array) {
15 for (var i = array.length - 1; i > 0; i--) {
16 var j = Math.floor(Math.random() * (i + 1));
17 var temp = array[i];
18 array[i] = array[j];
19 array[j] = temp;
20 }
21 return array;
22}
23
24alert(generatePassword(12));
1var Password = {
2
3 _pattern : /[a-zA-Z0-9_\-\+\.]/,
4
5
6 _getRandomByte : function()
7 {
8 // http://caniuse.com/#feat=getrandomvalues
9 if(window.crypto && window.crypto.getRandomValues)
10 {
11 var result = new Uint8Array(1);
12 window.crypto.getRandomValues(result);
13 return result[0];
14 }
15 else if(window.msCrypto && window.msCrypto.getRandomValues)
16 {
17 var result = new Uint8Array(1);
18 window.msCrypto.getRandomValues(result);
19 return result[0];
20 }
21 else
22 {
23 return Math.floor(Math.random() * 256);
24 }
25 },
26
27 generate : function(length)
28 {
29 return Array.apply(null, {'length': length})
30 .map(function()
31 {
32 var result;
33 while(true)
34 {
35 result = String.fromCharCode(this._getRandomByte());
36 if(this._pattern.test(result))
37 {
38 return result;
39 }
40 }
41 }, this)
42 .join('');
43 }
44
45};
1/*
2 This code comes from Vincent Lab
3 And it has a video version linked here: https://www.youtube.com/watch?v=PtnYuiIyqeM
4*/
5
6function generate() {
7
8 let password = "";
9
10 let length = +document.getElementById("length").value;
11
12 let lowerCase = document.getElementById("lowercase").checked;
13 let upperCase = document.getElementById("uppercase").checked;
14 let symbol = document.getElementById("symbols").checked;
15 let number = document.getElementById("numbers").checked;
16
17 if (lowerCase + upperCase + symbol + number <= 0)
18 return;
19
20 for (let i = 0; i < length; i++) {
21
22 const r = generater(0, 3);
23 if (lowerCase && r === 0) {
24 password += generateRandomLowerCase();
25 } else if (upperCase && r === 1) {
26 password += generateRandomUpperCase();
27 } else if (symbol && r === 2) {
28 password += generateRandomSymbol();
29 } else if (number && r === 3) {
30 password += generater(0, 9);
31 } else {
32 i--;
33 }
34
35 }
36
37 document.getElementById("result").textContent = password;
38
39}
40
41generate();
42
43function generateRandomLowerCase() {
44 return String.fromCharCode(generater(97, 122));
45}
46
47function generateRandomUpperCase() {
48 return String.fromCharCode(generater(65, 90));
49}
50
51function generateRandomSymbol() {
52 const symbols = "~*$%@#^&!?*'-=/,.{}()[]<>";
53 return symbols[generater(0, symbols.length - 1)];
54}
55
56function generater(min = 0, max = 1) {
57 return Math.floor(Math.random() * (max + 1 - min) + min);
58}
1 const Numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
2 const Names = ["Aaran", "Aaren", "Aodeba","Zaid", "Zain", "Zaine", "Zaineddine", "Zainedin", "Zak", "Zakaria", "Zakariya", "Zakary", "Zaki", "Zakir", "Zakk", "Zamaar", "Zander", "Zane", "Zarran", "Zayd", "Zayn", "Zayne", "Ze", "Zechariah", "Zeek", "Zeeshan", "Zeid", "Zein", "Zen", "Zendel", "Zenith", "Zennon", "Zeph", "Zerah", "Zhen", "Zhi", "Zhong", "Zhuo", "Zi", "Zidane", "Zijie", "Zinedine", "Zion", "Zishan", "Ziya", "Ziyaan", "Zohaib", "Zohair", "Zoubaeir", "Zubair", "Zubayr", "Zuriel"]
3 const Symbols = ["#", "£", "@", "%", "?", "!", "+", "$", "-", "*"]
4 const RandomName = Names[Math.floor(Math.random() * Names.length)];
5 const RandomNumber = Numbers[Math.floor(Math.random() * Numbers.length)];
6 const RandomNumber2 = Numbers[Math.floor(Math.random() * Numbers.length)];
7 const RandomSymbol = Symbols[Math.floor(Math.random() * Symbols.length)];
8 const RandomSymbol2 = Symbols[Math.floor(Math.random() * Symbols.length)];
9 const RandomSymbol3 = Symbols[Math.floor(Math.random() * Symbols.length)];
10 const RandomSymbol4 = Symbols[Math.floor(Math.random() * Symbols.length)];
11 const Password = `${RandomNumber2}${RandomSymbol}${RandomName}${RandomNumber}${RandomSymbol4}`
12 const Password2 = `${RandomNumber2}${RandomSymbol2}${RandomName}${RandomSymbol3}${RandomSymbol4}`
13 const Password3 = `${RandomNumber}${RandomNumber2}${RandomName}${RandomNumber}${RandomSymbol4}`
14 const Password4 = `${RandomSymbol2}${RandomSymbol3}${RandomName}${RandomNumber2}${RandomNumber}`
15 const Passwords = [Password, Password2, Password3, Password4]
16 const GeneratedPassword = Passwords[Math.floor(Math.random() * Passwords.length)];
17 const GeneratedPasswordToLowerCase = GeneratedPassword.toLowerCase()
18 /* Print The Passwords*/
19 console.log(GeneratedPassword)
20 console.log(GeneratedPasswordToLowerCase)
1function getpass() {
2 var chars = "0123456789~!@#$%^&*()_+}{[]|abcdefghikjlmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
3 var pass = "";
4 var passLength = 16;
5 for (var i = 0; i < passLength; i++) {
6 var randPass = Math.floor(Math.random() * chars.length);
7 pass += chars.substring(randPass, randPass+1);
8 }
9 document.getElementById('strong_pass').value = pass;
10}
11function copyToClipboard() {
12 var copyText = document.getElementById('strong_pass');
13 var copyPass = document.getElementById('strong_pass').value;
14 var fa_iocn = document.getElementsByClassName('fa');
15 if (copyPass == "") {
16 alert("Please Generate Password");
17 }else {
18 $(fa_iocn).removeClass("fa-copy");
19 $(fa_iocn).addClass("fa-check");
20 $("#strong_pass").addClass("focus_success");
21 alert("Password Copied Successfully")
22 }
23 copyText.select();
24 copyText.setSelectionRange(0, 99999);
25 document.execCommand("copy");
26}
27$(".strong_pass_generator #generatorbutton").click(function(){
28 $(".strong_pass_generator i").removeClass("fa-check");
29 $(".strong_pass_generator i").addClass("fa-copy");
30});
1<input type='text' id='p'/><br/>
2<input type='button' value ='generate' onclick='document.getElementById("p").value = Password.generate(16)'>