forked from blueimp/JavaScript-MD5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.js
More file actions
42 lines (39 loc) · 1.2 KB
/
demo.js
File metadata and controls
42 lines (39 loc) · 1.2 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
/*
* JavaScript MD5 Demo JS 1.0.1
* https://github.com/blueimp/JavaScript-MD5
*
* Copyright 2013, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
/*global window, $ */
$(function() {
'use strict';
$('#calculate').on('click', function(event) {
event.preventDefault();
var md5_password = {
usename: $('#usename').val(),
domain: $('#domain').val(),
salt: $('#salt').val()
}
if (localStorage) {
localStorage.setItem('md5_password', JSON.stringify(md5_password));
}
var cut=32;
if(parseInt($('#cut').val())){
cut=parseInt($('#cut').val());
}
$('#result').val(window.md5(md5_password.usename + md5_password.salt + md5_password.domain).substring(0,cut));
$('#result').focus(function() {
$(this).select();
})
});
if (localStorage && localStorage.md5_password) {
var md5_password = JSON.parse(localStorage.md5_password);
$('#usename').val(md5_password.usename);
$('#domain').val(md5_password.domain);
$('#salt').val(md5_password.salt);
}
});