-
Notifications
You must be signed in to change notification settings - Fork 0
/
passwordGenerator.html
185 lines (152 loc) · 4.14 KB
/
passwordGenerator.html
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Password Generator</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<style>
html {
min-height: 100%;
}
body {
min-height: 100%;
background-color: #2d3436;
background-image: linear-gradient(315deg, #2d3436 0%, #000000 74%);
text-align: center;
}
.slider {
-webkit-appearance: none;
width: 70%;
height: 10px;
background: #f7be04;
border-radius: 15px;
opacity: 1;
-webkit-transition: .2s;
transition: opacity .2s;
margin-left: 40px;
margin-top: 25px;
margin-bottom: 20px;
}
.slider:hover {
opacity: 0.5;
}
.slider::-webkit-slider-thumb {
-webkit-appearance: none;
width: 15px;
height: 15px;
background: #000000;
border-radius: 50%;
cursor: pointer;
}
.action-btn {
background-color: #000;
border: 0;
color: #f7be04;
font-size: 20px;
cursor: pointer padding: 10px;
margin: 10px 20px;
border-radius: 15px;
font-family: fantasy;
opacity: 1;
transition: opacity .2s;
}
.action-btn:hover {
opacity: 0.5;
}
.wrapper {
display: flex;
background-color: rgb(253, 253, 252);
flex-direction: column;
width: 30%;
margin-top: 10%;
margin-left: 35%;
border-radius: 15px;
font-family: fantasy;
padding-bottom: 1%;
}
.slider_main {
display: flex;
flex-direction: row;
}
output {
margin-top: 20px;
margin-left: 10px;
}
.wrapper_main {
display: flex;
background-color: rgb(253, 253, 252);
flex-direction: row;
width: 22%;
margin-top: 5%;
margin-left: 38%;
border-radius: 15px;
font-family: Georgia, serif;
padding-left: 45px;
}
.clipboard {
margin-left: auto;
cursor: pointer;
border: 0;
background-color: white;
color: black;
border-radius: 15px;
font-size: 23px;
opacity: 1;
transition: opacity .2s;
}
.clipboard:hover {
opacity: 0.5;
}
</style>
</head>
<body>
<div class="wrapper">
<button id="generate" class="action-btn">
Generate Password <i class="fab fa-keycdn"></i>
</button>
<div class="slider_main">
<input type="range" value="8" min="1" max="25" class="slider" oninput="this.nextElementSibling.value = this.value" id="slider">
<output>8</output>
</div>
<label class="container" style="font-family: fantasy;color: rgb(3, 3, 3);">Include special characters
<input type="checkbox" checked="checked" id="checkbox">
<span class="checkmark"></span>
</label>
</div>
<div class="wrapper_main">
<h5 id="pwd_txt"></h5>
<button id="clipboard" class="clipboard">
<i class="fas fa-clipboard"></i>
</button>
</div>
<script>
const password_ele = document.getElementById("pwd_txt");
var string = "ABCDEFGHIJKLMNOPQRSTUVWXYZacdefghijklnopqrstuvwxyz0123456789";
const special_chars = "@#$%^&*";
const generate = document.getElementById("generate");
const clipboard = document.getElementById("clipboard");
var pwd_length = document.getElementById("slider");
generate.addEventListener('click', () => {
let password = "";
var checked = document.getElementById("checkbox").checked;
var final_string = string;
console.log(checked);
if (checked) {
final_string += "@#$%^&*";
}
for (var i = 0; i < pwd_length.value; i++) {
let pwd = final_string[Math.floor(Math.random() * final_string.length)];
password += pwd;
}
password_ele.innerText = password;
final_string = string;
});
clipboard.addEventListener('click', () => {
navigator.clipboard.writeText(password_ele.innerText);
alert("Password copied to clipboard");
});
</script>
</body>
</html>