forked from neelimagprasad/CitrusHacks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpasswordGenerator.js
59 lines (46 loc) · 2.07 KB
/
passwordGenerator.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* Variable that holds current password to change via input from website */
var checker;
var submit = document.getElementById('generate');
var newpass = '';
/* Code for taking input from website */
document.getElementById('homeButton').addEventListener("click", function(event){
location.reload();
});
document.getElementById('generator').addEventListener("click", function(event){
event.preventDefault();
document.getElementById('passwordGenerator').style.display = "block" ;
document.getElementById('buttons').style.display = "none" ;
});
document.getElementById("generate").addEventListener("click", function(event){
event.preventDefault();
newpass = '';
var alphabet = "abcdefghijklmnopqrstuvwxyz";
var randletter = alphabet[Math.floor(Math.random() * alphabet.length)];
newpass += randletter;
var Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var randletter2 = Alphabet[Math.floor(Math.random() * Alphabet.length)];
newpass += randletter2;
var nums = "0123456789";
var randnum = nums[Math.floor(Math.random() * nums.length)];
newpass += randnum;
var specialchars = "!@#$%^&*";
var randchar = specialchars[Math.floor(Math.random() * specialchars.length)];
newpass += randchar;
var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*";
while (newpass.length < 10) {
newpass += chars[Math.floor(Math.random() * chars.length)];;
}
document.getElementById("suggestions").innerHTML = newpass;
document.getElementById('email_box').style.display= 'block';
});
document.getElementById("submit1").addEventListener("click", function(event){
event.preventDefault();
document.getElementById('linkshow').style.display= 'block';
var email = document.getElementById('email1').value;
var string = "mailto:"+email+"?subject= Secure Password&body= Your new password is "+newpass;
console.log(email);
console.log(string);
var link = document.getElementById("send");
link.innerHTML = "email";
link.setAttribute('href', string);
});