-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclasspass.html
More file actions
182 lines (152 loc) · 5.87 KB
/
classpass.html
File metadata and controls
182 lines (152 loc) · 5.87 KB
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
<!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>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
html{
color-scheme: light dark;
}
body{
height: 100vh;
}
.container {
height: 100vh;
display: grid;
place-items: center;
position: relative;
}
#content{
background: rgba(212, 212, 216,0.12);
height: 50vh;
width: 50%;
position: relative;
display:flex;
text-wrap: wrap;
flex-wrap: wrap;
box-shadow: inset 0 1px 5px rgba(255, 255, 255, 0.5),
0 1px 10px rgba(255, 255, 255, 0.5),
0 1px 20px rgba(255, 255, 255, 0.5);
border-radius: 10px;
justify-content: center;
align-items: flex-start;
flex-direction: column;
font-size: larger;
gap: 1rem;
}
#weak{
position: relative;
left: 20%;
color:red;
font-weight: bold;
text-align: center;
}
#medium{
position: relative;
left: 20%;
color:yellow;
font-weight: bold;
}
#strong{
position: relative;
left: 20%;
color:green;
font-weight: bold;
}
#funny{
position: relative;
left: 20%;
color:color-mix(in hsl shorter hue, rgb(0, 17, 255) 65%, rgb(128, 94, 0) 90%);
font-weight: bold;
}
</style>
</head>
<body>
<div class="container">
<div id="content">
<div id="weak"></div>
<div id="medium"></div>
<div id="strong"></div>
<div id="funny"></div>
</div>
</div>
<script>
const chars = `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!#$%&@^*(){+-}/~'";?!`
const randomChar = () => chars[Math.floor(Math.random() * (chars.length - 1))],
randomString = length => Array.from(Array(length)).map(randomChar).join("")
// console.log(chars.length - 1)
class Password {
constructor(randomString) {
this.randomString = randomString
console.log(randomString)
}
weakPassword() {
function filterElement(element) {
const regex = /^[a-z]*$/
return regex.test(element);
}
const elements = randomString(len - 72)
const arrayofvalues = Object.values(elements)
console.log(arrayofvalues + ' Original Value Before Filter')
const filteredElements = arrayofvalues.filter(filterElement);
console.log("weak password(AFTER FILTER)")
const weakpass = filteredElements.join('')
console.log(weakpass);
const div =document.getElementById("weak")
div.textContent += `Weak Password : ${weakpass}`
}
mediumPassword() {
function filterElement(element) {
const regex = /^[a-zA-Z0-9]*$/
return regex.test(element);
}
const elements = randomString(len - 70)
const arrayofvalues = Object.values(elements)
console.log(arrayofvalues + ' Original Value Before Filter')
const filteredElements = arrayofvalues.filter(filterElement);
console.log("medium password(AFTER FILTER)")
const mediumpass = filteredElements.join('')
console.log(mediumpass);
const div = document.getElementById("medium")
div.textContent += `Medium Password : ${mediumpass}`
}
strongPassword() {
function filterElement(element) {
const regex = /^[a-zA-Z0-9-!#$%&@^*(){+-}/~'";?!]*$/
return regex.test(element);
}
const elements = randomString(len - 65)
const arrayofvalues = Object.values(elements)
console.log(arrayofvalues + ' Original Value Before Filter')
const filteredElements = arrayofvalues.filter(filterElement);
console.log("strong password(AFTER FILTER)")
const strongpass = filteredElements.join('')
console.log(strongpass);
const div = document.getElementById("strong")
div.textContent += `Strong Password : ${strongpass}`
}
funnyPassword() {
const funnyArray = ["password", "enteryourpassword", "idonthaveanypassword", "iforgotthepassword", "funnypassword", "getawayfromhere",
"mypasswordisfunny", "youcanthackmypassword", "nevertellyournextmove", "yourphonenumber"]
const funnyRandom = Math.floor(Math.random() * funnyArray.length)
const funnyPass = funnyArray[funnyRandom]
console.log(funnyPass)
const div = document.getElementById("funny")
div.textContent += `Funny Password : ${funnyPass}`
}
}
let len = chars.length - 1
let p = password = new Password(randomString(len))
const weak = p.weakPassword(),
medium = p.mediumPassword(),
strong = p.strongPassword(),
funny = p.funnyPassword()
</script>
</body>
</html>