-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
35 lines (29 loc) · 1.18 KB
/
Copy pathapp.js
File metadata and controls
35 lines (29 loc) · 1.18 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
29
30
31
32
33
34
35
//This is the JS FIle for the Random Password Generator Project
const passwordBox = document.getElementById("Password");
//length variable of the generated password
const length =15;
//Password Dataset
const upperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const lowerCase = "abcdefghijklmnopqrstuvwxyz";
const number = "0123456789";
const symbol = "~!@#$%^&*()_+{}[];:'\|?/.,";
const allChars = upperCase + lowerCase + number + symbol;
//Password Generator Function
function passwordGenerator(){
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+= allChars[Math.floor(Math.random()* allChars.length)];
}
passwordBox.value = password;
}
//Copy Password from the Copy Password Icon
function copyPassword(){
passwordBox.select();
navigator.clipboard.writeText(password)
// document.execCommand('copy');
alert("Password is copied to Clipboard");
}