forked from mrjooz/password-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
170 lines (160 loc) · 6.34 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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>密码生成工具</title>
<link rel="shortcut icon" href="favicon.ico" />
<link type="text/css" rel="stylesheet" href="css/bootstrap.min.css" media="screen,projection" />
</head>
<body>
<div class="container mt-5">
<div class="row justify-content-center">
<div class="input-field col-12 col-sm-12 col-md-8 col-lg-6">
<div class="alert alert-warning" role="alert">
说明
<ol>
<li>密码计算全部在本地进行</li>
<li>记忆密码复杂一点(固定)</li>
<li>区分代码按一定规则:比如QQ密码区分代码为qq</li>
</ol>
</div>
<form>
<!--记忆密码-->
<div class="input-group mb-2 mr-sm-2">
<div class="input-group-prepend">
<span class="input-group-text">🔑</span>
<div class="input-group-text">记忆密码</div>
</div>
<input type="password" class="form-control" id="pwd" placeholder="Memory Password" value="" />
<div class="input-group-prepend">
<span class="input-group-text" onclick="change_show_status('pwd')"
onmouseover="this.style.cursor='pointer'">显示</span>
</div>
</div>
<!--区分代码-->
<div class="input-group mb-2 mr-sm-2">
<div class="input-group-prepend">
<div class="input-group-text">🏷️</div>
<div class="input-group-text">区分代码</div>
</div>
<input type="text" class="form-control" id="key" placeholder="Distinguish Code" value="" />
</div>
<!--密码长度-->
<div class="input-group mb-3">
<div class="input-group-prepend">
<label class="input-group-text" for="pwd_length">📏</label>
<label class="input-group-text" for="pwd_length">密码长度</label>
</div>
<select class="custom-select" id="pwd_length">
<option value="10">10 位</option>
<option value="11">11 位</option>
<option value="12">12 位</option>
<option value="13">13 位</option>
<option value="14">14 位</option>
<option value="15">15 位</option>
<option value="16" selected>16 位</option>
<option value="17">17 位</option>
<option value="18">18 位</option>
<option value="19">19 位</option>
<option value="20">20 位</option>
</select>
</div>
<!-- 选项 -->
<div class="input-group mb-3">
<select class="custom-select" id="rule_of_punctuation">
<option value="1" selected>使用标点</option>
<option value="-1">禁用标点</option>
</select>
<div class="input-group-prepend">
<label class="input-group-text">选项</label>
</div>
<select class="custom-select" id="rule_of_letter">
<option value="1" selected>字母区分大小写</option>
<option value="-1">字母全小写</option>
</select>
</div>
<!-- 复制密码 -->
<div class="form-group">
<div class="input-group mb-3">
<input type="text" class="form-control" id="code" placeholder="Encrypted Password" value="" readonly />
<div class="input-group-append">
<button class="btn btn-secondary" type="button" id="btn_copy" data-clipboard-target="#code">
复制Copy
</button>
</div>
</div>
<div class="progress">
<div class="progress-bar" id="quality_progress" role="progressbar" style="width: 0%"></div>
</div>
</div>
<div class="form-group">
<div class="row justify-content-center">
<button class="btn btn-primary" type="button" id="btn_gencode">
生成Generate
</button>
</div>
</div>
</form>
</div>
</div>
</div>
<script type="text/javascript" src="js/clipboard.min.js"></script>
<script type="text/javascript" src="js/sha512.min.js"></script>
<script type="text/javascript" src="js/PasswordQualityCalculator.min.js"></script>
<script type="text/javascript" src="src/seek_password.min.js"></script>
<script type="text/javascript">
var clipboard = new ClipboardJS("#btn_copy");
document.getElementById("btn_gencode").onclick = function () {
var sk_pwd = generate_password();
if (sk_pwd) {
document.getElementById("code").value = sk_pwd;
}
//密码强度
const quality = PasswordQualityCalculator(
document.getElementById("code").value
);
//清除记录
var quality_progress = document.getElementById("quality_progress");
quality_progress.className = "progress-bar";
if (quality > 0 && quality <= 64) {
quality_progress.classList.add("bg-danger");
quality_progress.style.setProperty(
"width",
(quality / 120) * 100 + "%"
);
quality_progress.innerText = "极弱";
} else if (quality > 64 && quality <= 80) {
quality_progress.classList.add("bg-warning");
quality_progress.style.setProperty(
"width",
(quality / 120) * 100 + "%"
);
quality_progress.innerText = "弱";
} else if (quality > 80 && quality <= 112) {
quality_progress.style.setProperty(
"width",
(quality / 120) * 100 + "%"
);
quality_progress.innerText = "强";
} else if (quality > 112) {
quality_progress.classList.add("bg-success");
quality_progress.style.setProperty(
"width",
(quality / 120) * 100 + "%"
);
quality_progress.innerText = "极强";
}
};
//显示&隐藏密码
function change_show_status(input_id) {
var input = document.getElementById("pwd");
if (input.getAttribute("type") == "password") {
input.setAttribute("type", "text");
} else {
input.setAttribute("type", "password");
}
}
</script>
</body>
</html>