Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7dc97b2

Browse files
committed
Refactored demo implementation.
Added bower.json.
1 parent d2a38e4 commit 7dc97b2

12 files changed

+190
-94
lines changed

Makefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
.PHONY: js
1+
.PHONY: default js
2+
3+
default: js
24

35
js:
4-
uglifyjs -nc md5.js > md5.min.js
6+
node_modules/.bin/uglifyjs js/md5.js -c -m -o js/md5.min.js

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
# JavaScript MD5
22

33
## Demo
4-
[JavaScript MD5 Demo](http://blueimp.github.com/JavaScript-MD5/)
4+
[JavaScript MD5 Demo](http://blueimp.github.io/JavaScript-MD5/)
5+
6+
## Description
7+
JavaScript MD5 implementation. Compatible with server-side environments like node.js, module loaders like RequireJS and all web browsers.
58

69
## Usage
710

811
### Client-side
912
Include the (minified) JavaScript [MD5](http://en.wikipedia.org/wiki/MD5) script in your HTML markup:
1013

1114
```html
12-
<script src="md5.min.js"></script>
15+
<script src="js/md5.min.js"></script>
1316
```
1417

1518
In your application code, calculate the ([hex](http://en.wikipedia.org/wiki/Hexadecimal)-encoded) [MD5](http://en.wikipedia.org/wiki/MD5) hash of a string by calling the **md5** method with the string as argument:

bower.json

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"name": "blueimp-md5",
3+
"version": "1.0.1",
4+
"title": "JavaScript MD5",
5+
"description": "JavaScript MD5 implementation.",
6+
"keywords": [
7+
"javascript",
8+
"md5"
9+
],
10+
"homepage": "https://github.com/blueimp/JavaScript-MD5",
11+
"author": {
12+
"name": "Sebastian Tschan",
13+
"url": "https://blueimp.net"
14+
},
15+
"maintainers": [
16+
{
17+
"name": "Sebastian Tschan",
18+
"url": "https://blueimp.net"
19+
}
20+
],
21+
"contributors": [
22+
{
23+
"name": "Paul Johnston",
24+
"url": "http://pajhome.org.uk/crypt/md5"
25+
}
26+
],
27+
"repository": {
28+
"type": "git",
29+
"url": "git://github.com/blueimp/JavaScript-MD5.git"
30+
},
31+
"bugs": "https://github.com/blueimp/JavaScript-MD5/issues",
32+
"licenses": [
33+
{
34+
"type": "MIT",
35+
"url": "http://www.opensource.org/licenses/MIT"
36+
}
37+
],
38+
"devDependencies": {
39+
"mocha": "1.11.0",
40+
"expect.js": "0.2.0",
41+
"uglify-js": "2.3.6"
42+
},
43+
"scripts": {
44+
"test": "mocha --reporter spec"
45+
},
46+
"main": "js/md5.js"
47+
}

css/demo.css

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* JavaScript MD5 Demo CSS 1.0.1
3+
* https://github.com/blueimp/JavaScript-MD5
4+
*
5+
* Copyright 2013, Sebastian Tschan
6+
* https://blueimp.net
7+
*
8+
* Licensed under the MIT license:
9+
* http://www.opensource.org/licenses/MIT
10+
*/
11+
12+
body {
13+
max-width: 750px;
14+
margin: 0 auto;
15+
padding: 1em;
16+
font-family: 'Lucida Grande', 'Lucida Sans Unicode', Arial, sans-serif;
17+
font-size: 1em;
18+
line-height: 1.4em;
19+
background: #222;
20+
color: #fff;
21+
-webkit-text-size-adjust: 100%;
22+
-ms-text-size-adjust: 100%;
23+
}
24+
a {
25+
color: orange;
26+
text-decoration: none;
27+
}
28+
img {
29+
border: 0;
30+
vertical-align: middle;
31+
}
32+
h1 {
33+
line-height: 1em;
34+
}
35+
textarea,
36+
input {
37+
display: inline-block;
38+
width: 100%;
39+
-webkit-box-sizing: border-box;
40+
-moz-box-sizing: border-box;
41+
box-sizing: border-box;
42+
padding: 10px;
43+
margin: 0 0 10px;
44+
}
45+
46+
@media (min-width: 481px) {
47+
.navigation {
48+
list-style: none;
49+
padding: 0;
50+
}
51+
.navigation li {
52+
display: inline-block;
53+
}
54+
.navigation li:not(:first-child):before {
55+
content: '| ';
56+
}
57+
}
58+
59+
/* IE7 fixes */
60+
*+html textarea,
61+
*+html input {
62+
width: 460px;
63+
}

index.html

+29-74
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE HTML>
22
<!--
33
/*
4-
* JavaScript MD5 Demo 1.0
4+
* JavaScript MD5 Demo 1.0.1
55
* https://github.com/blueimp/JavaScript-MD5
66
*
77
* Copyright 2011, Sebastian Tschan
@@ -13,84 +13,39 @@
1313
-->
1414
<html lang="en">
1515
<head>
16-
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><![endif]-->
16+
<!--[if IE]>
17+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
18+
<![endif]-->
1719
<meta charset="utf-8">
1820
<title>JavaScript MD5 Demo</title>
1921
<meta name="description" content="JavaScript MD5 implementation. Compatible with server-side environments like node.js, module loaders like RequireJS and all web browsers.">
20-
<meta name="viewport" content="width=device-width">
21-
<link rel="stylesheet" href="http://blueimp.github.com/cdn/css/bootstrap.min.css">
22-
<style>body{padding-top:60px;}</style>
23-
<link rel="stylesheet" href="http://blueimp.github.com/cdn/css/bootstrap-responsive.min.css">
24-
<!--[if lt IE 7]><link rel="stylesheet" href="http://blueimp.github.com/cdn/css/bootstrap-ie6.min.css"><![endif]-->
25-
<!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
22+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
23+
<link rel="stylesheet" href="css/demo.css">
2624
</head>
2725
<body>
28-
<div class="navbar navbar-fixed-top">
29-
<div class="navbar-inner">
30-
<div class="container">
31-
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
32-
<span class="icon-bar"></span>
33-
<span class="icon-bar"></span>
34-
<span class="icon-bar"></span>
35-
</a>
36-
<a class="brand" href="https://github.com/blueimp/JavaScript-MD5">JavaScript MD5</a>
37-
<div class="nav-collapse">
38-
<ul class="nav">
39-
<li class="active"><a href="#">Demo</a></li>
40-
<li><a href="https://github.com/blueimp/JavaScript-MD5/downloads">Downloads</a></li>
41-
<li><a href="https://github.com/blueimp/JavaScript-MD5">Source Code</a></li>
42-
<li><a href="https://github.com/blueimp/JavaScript-MD5">Documentation</a></li>
43-
<li><a href="https://github.com/blueimp/JavaScript-MD5/issues">Issues</a></li>
44-
<li><a href="test/">Test</a></li>
45-
<li><a href="https://blueimp.net">&copy; Sebastian Tschan</a></li>
46-
</ul>
47-
</div>
48-
</div>
49-
</div>
50-
</div>
51-
<div class="container">
52-
<div class="page-header">
53-
<h1>JavaScript MD5 Demo</h1>
54-
</div>
55-
<blockquote>
56-
<p>JavaScript <a href="http://en.wikipedia.org/wiki/MD5">MD5</a> implementation.<br>
57-
Compatible with server-side environments like <a href="http://nodejs.org/">node.js</a>, module loaders like <a href="http://requirejs.org/">RequireJS</a> and all web browsers.</p>
58-
</blockquote>
26+
<h1>JavaScript MD5 Demo</h1>
27+
<p>JavaScript <a href="http://en.wikipedia.org/wiki/MD5">MD5</a> implementation.<br>
28+
Compatible with server-side environments like <a href="http://nodejs.org/">node.js</a>, module loaders like <a href="http://requirejs.org/">RequireJS</a> and all web browsers.</p>
29+
<ul class="navigation">
30+
<li><a href="https://github.com/blueimp/JavaScript-MD5/tags">Download</a></li>
31+
<li><a href="https://github.com/blueimp/JavaScript-MD5">Source Code</a></li>
32+
<li><a href="https://github.com/blueimp/JavaScript-MD5/blob/master/README.md">Documentation</a></li>
33+
<li><a href="test/">Test</a></li>
34+
<li><a href="https://blueimp.net">&copy; Sebastian Tschan</a></li>
35+
</ul>
36+
<form>
37+
<h2>Input</h2>
38+
<textarea rows="6" id="input"></textarea>
5939
<br>
60-
<div class="row">
61-
<div class="span7">
62-
<h2>Input</h2>
63-
<textarea class="span7" rows="6" id="input"></textarea>
64-
</div>
65-
<div class="span5">
66-
<h2>Result</h2>
67-
<div class="well" id="result"></div>
68-
<p>
69-
<button class="btn btn-primary" id="calculate">Calculate</button>
70-
<button class="btn" type="reset" id="reset">Reset</button>
71-
</p>
72-
</div>
73-
</div>
74-
</div>
75-
<script src="md5.min.js"></script>
76-
<!-- jQuery and Bootstrap JS are not required, but included for the demo -->
77-
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
78-
<script src="http://blueimp.github.com/cdn/js/bootstrap.min.js"></script>
79-
<script>
80-
/*global jQuery, window */
81-
(function ($) {
82-
'use strict';
83-
var calculate = function () {
84-
$('#result').html(window.md5($('#input').val()));
85-
},
86-
init = function () {
87-
$('#input').val('日本');
88-
$('#result').empty();
89-
};
90-
init();
91-
$('#calculate').on('click', calculate);
92-
$('#reset').on('click', init);
93-
}(jQuery));
94-
</script>
40+
<button type="submit" id="calculate">Calculate</button>
41+
<button type="reset" id="reset">Reset</button>
42+
<h2>Result</h2>
43+
<input id="result">
44+
<br>
45+
</form>
46+
<script src="js/md5.js"></script>
47+
<!-- jQuery is not required by the Gallery, but included for the demo -->
48+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
49+
<script src="js/demo.js"></script>
9550
</body>
9651
</html>

js/demo.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* JavaScript MD5 Demo JS 1.0.1
3+
* https://github.com/blueimp/JavaScript-MD5
4+
*
5+
* Copyright 2013, Sebastian Tschan
6+
* https://blueimp.net
7+
*
8+
* Licensed under the MIT license:
9+
* http://www.opensource.org/licenses/MIT
10+
*/
11+
12+
/*global window, $ */
13+
14+
$(function () {
15+
'use strict';
16+
17+
$('#calculate').on('click', function (event) {
18+
event.preventDefault();
19+
$('#result').val(window.md5($('#input').val()));
20+
});
21+
$('#input').val('日本');
22+
23+
});

md5.js renamed to js/md5.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* JavaScript MD5 1.0
2+
* JavaScript MD5 1.0.1
33
* https://github.com/blueimp/JavaScript-MD5
44
*
55
* Copyright 2011, Sebastian Tschan
@@ -64,7 +64,7 @@
6464
*/
6565
function binl_md5(x, len) {
6666
/* append padding */
67-
x[len >> 5] |= 0x80 << ((len) % 32);
67+
x[len >> 5] |= 0x80 << (len % 32);
6868
x[(((len + 64) >>> 9) << 4) + 14] = len;
6969

7070
var i, olda, oldb, oldc, oldd,

js/md5.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

md5.min.js

-1
This file was deleted.

package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "blueimp-md5",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"title": "JavaScript MD5",
55
"description": "JavaScript MD5 implementation.",
66
"keywords": [
@@ -36,11 +36,12 @@
3636
}
3737
],
3838
"devDependencies": {
39-
"mocha": "latest",
40-
"expect.js": "latest"
39+
"mocha": "1.11.0",
40+
"expect.js": "0.2.0",
41+
"uglify-js": "2.3.6"
4142
},
4243
"scripts": {
4344
"test": "mocha --reporter spec"
4445
},
45-
"main": "md5.js"
46+
"main": "js/md5.js"
4647
}

test/index.html

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE HTML>
22
<!--
33
/*
4-
* JavaScript MD5 Test 1.0
4+
* JavaScript MD5 Test 1.0.1
55
* https://github.com/blueimp/JavaScript-MD5
66
*
77
* Copyright 2011, Sebastian Tschan
@@ -13,24 +13,26 @@
1313
-->
1414
<html lang="en">
1515
<head>
16-
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><![endif]-->
16+
<!--[if IE]>
17+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
18+
<![endif]-->
1719
<meta charset="utf-8">
1820
<title>JavaScript MD5 Test</title>
19-
<meta name="viewport" content="width=device-width">
20-
<link rel="stylesheet" href="http://blueimp.github.com/cdn/css/mocha.min.css">
21+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
22+
<link rel="stylesheet" href="http://blueimp.github.io/cdn/css/mocha.min.css">
2123
</head>
2224
<body>
2325
<div id="mocha"></div>
2426
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
25-
<script src="http://blueimp.github.com/cdn/js/mocha.min.js"></script>
26-
<script src="http://blueimp.github.com/cdn/js/expect.min.js"></script>
27+
<script src="http://blueimp.github.io/cdn/js/mocha.min.js"></script>
28+
<script src="http://blueimp.github.io/cdn/js/expect.min.js"></script>
2729
<script>
2830
mocha.setup('bdd');
2931
$(function () {
3032
mocha.run();
3133
});
3234
</script>
33-
<script src="../md5.js"></script>
35+
<script src="../js/md5.js"></script>
3436
<script src="test.js"></script>
3537
</body>
3638
</html>

test/test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* JavaScript MD5 Test 1.0
2+
* JavaScript MD5 Test 1.0.1
33
* https://github.com/blueimp/JavaScript-MD5
44
*
55
* Copyright 2011, Sebastian Tschan
@@ -96,5 +96,5 @@
9696

9797
}(
9898
this.expect || require('expect.js'),
99-
this.md5 || require('../md5').md5
99+
this.md5 || require('../js/md5').md5
100100
));

0 commit comments

Comments
 (0)