-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
53 lines (47 loc) · 2.2 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="shortcut icon" type="x-icon" href="https://img.icons8.com/?size=100&id=OOZ03zZyUcSR&format=png&color=000000">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Random Password Generator</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
<body>
<div class="container">
<h1>Generate a <br><span>Random Password</span></h1>
<div class="display">
<input type="text" id="password" placeholder="Password">
<div class="icon">
<i class="fa-solid fa-copy" onclick="copyPassword()"></i>
</div>
<button onclick ="createPassword()"><span><i class="fa-solid fa-lock"></i> Generate </span> </button>
</div>
</div>
<script>
const passwordBox = document.getElementById("password");
const lenght = 12;
const upperCase ="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const lowerCase ="abcdefghijklmnopqrstuvwxyz";
const number ="0123456789";
const symbol ="!@#$%^&*()_-|\><";
const allCharc = upperCase + lowerCase + number + symbol;
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 += symbol[Math.floor(Math.random() * symbol.length)];
while(lenght > password.length){
password += allCharc[Math.floor(Math.random() * allCharc.length)];
}
passwordBox.value = password;
}
function copyPassword(){
passwordBox.select();
document.execCommand("copy");
}
</script>
</body>
</html>