Skip to content
This repository was archived by the owner on Sep 25, 2021. It is now read-only.

Commit 50ac731

Browse files
committed
密码生成器
1 parent e501057 commit 50ac731

3 files changed

Lines changed: 28 additions & 5 deletions

File tree

‎index.html‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ <h1>JavaScript MD5 Demo</h1>
3535
</ul>
3636
<form>
3737
<h2>Input</h2>
38-
<textarea rows="6" id="input"></textarea>
38+
<input placeholder="用户名" id="usename" required />
39+
<input placeholder="域名,test.com" id="domain" required />
40+
<input placeholder="盐" id="salt" required />
3941
<br>
4042
<button type="submit" id="calculate">Calculate</button>
4143
<button type="reset" id="reset">Reset</button>
@@ -45,7 +47,7 @@ <h2>Result</h2>
4547
</form>
4648
<script src="js/md5.js"></script>
4749
<!-- jQuery is not required by JavaScript MD5, but included for the demo -->
48-
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
50+
<script src="js/jquery.min.js"></script>
4951
<script src="js/demo.js"></script>
5052
</body>
5153
</html>

‎js/demo.js‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,23 @@ $(function () {
1616

1717
$('#calculate').on('click', function (event) {
1818
event.preventDefault();
19-
$('#result').val(window.md5($('#input').val()));
19+
var md5_password={
20+
usename:$('#usename').val(),
21+
domain:$('#domain').val(),
22+
salt:$('#salt').val()
23+
}
24+
if(localStorage){
25+
localStorage.setItem('md5_password',JSON.stringify(md5_password));
26+
}
27+
$('#result').val(window.md5(md5_password.usename+md5_password.salt+md5_password.domain));
28+
$('#result').focus(function(){
29+
$(this).select();
30+
})
2031
});
21-
$('#input').val('日本');
22-
32+
if(localStorage&&localStorage.md5_password){
33+
var md5_password=JSON.parse(localStorage.md5_password);
34+
$('#usename').val(md5_password.usename);
35+
$('#domain').val(md5_password.domain);
36+
$('#salt').val(md5_password.salt);
37+
}
2338
});

0 commit comments

Comments
 (0)