-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
114 lines (106 loc) · 3.99 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Password Generator by - KARTIK SHARMA</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body {
background-color: #f7f7f7;
font-family: Arial, sans-serif;
}
.container {
max-width: 500px;
margin-top: 50px;
padding: 20px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
}
.result {
margin-top: 20px;
font-size: 18px;
text-align: center;
font-weight: bold;
}
#dark-mode-btn {
position: absolute;
top: 10px;
right: 10px;
background-color: #444;
color: white;
border: none;
padding: 10px;
border-radius: 5px;
}
body.dark-mode {
background-color: #333;
color: #ddd;
}
.container.dark-mode {
background-color: #444;
color: #eee;
}
</style>
</head>
<body>
<button id="dark-mode-btn">Dark Mode</button>
<div class="container">
<h3>Password Generator</h3>
<div class="mb-3">
<label for="password-length">Length:</label>
<input type="number" id="password-length" value="12" min="6" max="20">
</div>
<div class="form-check">
<input type="checkbox" id="uppercase" checked>
<label for="uppercase">Include Uppercase Letters</label>
</div>
<div class="form-check">
<input type="checkbox" id="numbers" checked>
<label for="numbers">Include Numbers</label>
</div>
<div class="form-check">
<input type="checkbox" id="special" checked>
<label for="special">Include Special Characters</label>
</div>
<button id="generate-password" class="btn btn-primary mt-3">Generate</button>
<div class="result" id="password-result"></div>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<script>
// dark mode
let darkMode = false;
const darkModeBtn = document.getElementById('dark-mode-btn');
const body = document.body;
const container = document.querySelector('.container');
darkModeBtn.onclick = function() {
darkMode = !darkMode;
body.classList.toggle('dark-mode', darkMode);
container.classList.toggle('dark-mode', darkMode);
darkModeBtn.textContent = darkMode ? 'Light Mode' : 'Dark Mode';
};
// passowrd generate fnctn
document.getElementById('generate-password').onclick = function() {
const length = document.getElementById('password-length').value;
const useUppercase = document.getElementById('uppercase').checked;
const useNumbers = document.getElementById('numbers').checked;
const useSpecial = document.getElementById('special').checked;
const lowercase = 'abcdefghijklmnopqrstuvwxyz';
const uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
const numbers = '0123456789';
const specialChars = '!@#$%^&*()_+-=[]{}|;:,.<>?';
let characters = lowercase;
if (useUppercase) characters += uppercase;
if (useNumbers) characters += numbers;
if (useSpecial) characters += specialChars;
let password = '';
for (let i = 0; i < length; i++) {
password += characters.charAt(Math.floor(Math.random() * characters.length));
}
// output password
document.getElementById('password-result').textContent = password;
};
</script>
</body>
</html>