This repository was archived by the owner on Sep 25, 2021. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 >
Original file line number Diff line number Diff 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} ) ;
You can’t perform that action at this time.
0 commit comments