-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
28 lines (25 loc) · 1.02 KB
/
Copy pathscript.js
File metadata and controls
28 lines (25 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const passwordBox = document.getElementById('Password');
var button = document.getElementById('button');
var copyPassword = document.getElementById('copy');
const length = 12;
const upperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const lowerCase = "abcdefghijklmnopqrstuvwxyz";
const number = "0123456789";
const symbol = "@#$%^&*()_~+|{}[]></-=";
const allChar = upperCase + lowerCase + number + symbol;
button.addEventListener('click',function(){
let password = "";
password += upperCase[Math.floor(Math.random()*upperCase.length)];
password += lowerCase[Math.floor(Math.random()*lowerCase.length)];
password += number[Math.floor(Math.random()*number.length)];
password += symbol[Math.floor(Math.random()*symbol.length)];
while(length > password.length){
password += allChar[Math.floor(Math.random()*allChar.length)];
}
console.log(password);
passwordBox.value = password;
});
copyPassword.addEventListener('click',function(){
passwordBox.select();
document.execCommand('copy');
})