-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
25 lines (22 loc) · 850 Bytes
/
Copy pathscript.js
File metadata and controls
25 lines (22 loc) · 850 Bytes
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
const passwordBox = document.getElementById('password');
const length = 14;
const upperCase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
const lowerCase = 'abcdefghijklmnopqrstuvwxyz';
const number = '0123456789';
const symbols = '@#$%^&*_+~|/?-=';
const allChars = upperCase + lowerCase + number + symbols;
function createPassword() {
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 += symbols[Math.floor(Math.random()*symbols.length)];
while(length>password.length){
password += allChars[Math.floor(Math.random()*allChars.length)];
}
passwordBox.value = password;
}
function copyPassword() {
passwordBox.select();
document.execCommand('copy');
}