-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate.html
107 lines (107 loc) · 3.28 KB
/
generate.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body{
background-color: rgb(97, 42, 149);
padding: 0;
margin: 0;
font-style: italic;
font-weight: 19px;
}
.container{
width: 100%;
max-width: 540px;
margin: 15%;
}
.container h1{
color: #fff;
padding: 10px;
}
.password{
text-decoration: underline;
}
.showgen{
width: 100%;
margin-top: 30px;
margin-bottom: 30px;
background-color: #fff;
color: #333;
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px;
border-radius: 8px;
}
.showgen input{
padding: 9px;
font-size: 16px;
border: none;
outline: none;
width: 100%;
}
.showgen img{
cursor: pointer;
}
.btn{
background-color: green;
font-size: 22px;
border: 0;
outline: 0;
cursor: pointer;color: #fff;
font-weight: 300px;
display: flex;
align-items: center;
justify-content: center;
padding: 16px 25px;
border-radius: 6px;
}
.btn img{
width: 24px;
height: 24px;
margin-right: 10px;
padding-top: 4px;
}
</style>
</head>
<body>
<div class="container">
<h1>Generate a <br>
<span class="password">Random Password</span></h1>
<div class="showgen">
<input type="text" id="inp">
<img src="https://static.vecteezy.com/system/resources/previews/000/423/339/original/copy-icon-vector-illustration.jpg" width="40px" height="40px" onclick="copyPassword()">
</div>
<button class="btn" onclick="createPassword()">
<img src="https://th.bing.com/th/id/OIP.SY6RYhgscN_t0GyBeM7ktgAAAA?pid=ImgDet&rs=1" alt="" width="26px" height="26px"> Generate Password
</button>
</div>
<script>
let passwordBox = document.getElementById("inp");
const leng = 12;
const upperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const lowerCase = "abcdefghijklmnopqrstuvwxyz";
const numbers = "1234567890";
const symbols = "~!@#$%^&*()_+?/\]{}[";
const allChars = upperCase + lowerCase + numbers + symbols;
function createPassword(){
let password = "";
password += upperCase[Math.floor(Math.random() * upperCase.length)];
password += lowerCase[Math.floor(Math.random() * lowerCase.length)];
password += numbers[Math.floor(Math.random() * numbers.length)];
password += symbols[Math.floor(Math.random() * symbols.length)];
while(leng > password.length){
password += allChars[Math.floor(Math.random() * allChars.length)];
}
passwordBox.value = password;
}
function copyPassword(){
passwordBox.select();
document.execCommand("copy");
}
</script>
</body>
</html>