From 7dc97b244935565842e495e8c532b7cd87b5e7fa Mon Sep 17 00:00:00 2001 From: Sebastian Tschan Date: Wed, 26 Jun 2013 16:27:06 -0500 Subject: [PATCH 01/80] Refactored demo implementation. Added bower.json. --- Makefile | 6 ++- README.md | 7 ++- bower.json | 47 ++++++++++++++++++++ css/demo.css | 63 +++++++++++++++++++++++++++ index.html | 103 +++++++++++++------------------------------- js/demo.js | 23 ++++++++++ md5.js => js/md5.js | 4 +- js/md5.min.js | 1 + md5.min.js | 1 - package.json | 9 ++-- test/index.html | 16 ++++--- test/test.js | 4 +- 12 files changed, 190 insertions(+), 94 deletions(-) create mode 100644 bower.json create mode 100644 css/demo.css create mode 100644 js/demo.js rename md5.js => js/md5.js (99%) create mode 100644 js/md5.min.js delete mode 100644 md5.min.js diff --git a/Makefile b/Makefile index efcc8a6..a196ee8 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ -.PHONY: js +.PHONY: default js + +default: js js: - uglifyjs -nc md5.js > md5.min.js + node_modules/.bin/uglifyjs js/md5.js -c -m -o js/md5.min.js diff --git a/README.md b/README.md index 6496c3f..a476f40 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ # JavaScript MD5 ## Demo -[JavaScript MD5 Demo](http://blueimp.github.com/JavaScript-MD5/) +[JavaScript MD5 Demo](http://blueimp.github.io/JavaScript-MD5/) + +## Description +JavaScript MD5 implementation. Compatible with server-side environments like node.js, module loaders like RequireJS and all web browsers. ## Usage @@ -9,7 +12,7 @@ Include the (minified) JavaScript [MD5](http://en.wikipedia.org/wiki/MD5) script in your HTML markup: ```html - + ``` 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: diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..819935b --- /dev/null +++ b/bower.json @@ -0,0 +1,47 @@ +{ + "name": "blueimp-md5", + "version": "1.0.1", + "title": "JavaScript MD5", + "description": "JavaScript MD5 implementation.", + "keywords": [ + "javascript", + "md5" + ], + "homepage": "https://github.com/blueimp/JavaScript-MD5", + "author": { + "name": "Sebastian Tschan", + "url": "https://blueimp.net" + }, + "maintainers": [ + { + "name": "Sebastian Tschan", + "url": "https://blueimp.net" + } + ], + "contributors": [ + { + "name": "Paul Johnston", + "url": "http://pajhome.org.uk/crypt/md5" + } + ], + "repository": { + "type": "git", + "url": "git://github.com/blueimp/JavaScript-MD5.git" + }, + "bugs": "https://github.com/blueimp/JavaScript-MD5/issues", + "licenses": [ + { + "type": "MIT", + "url": "http://www.opensource.org/licenses/MIT" + } + ], + "devDependencies": { + "mocha": "1.11.0", + "expect.js": "0.2.0", + "uglify-js": "2.3.6" + }, + "scripts": { + "test": "mocha --reporter spec" + }, + "main": "js/md5.js" +} diff --git a/css/demo.css b/css/demo.css new file mode 100644 index 0000000..209bbbc --- /dev/null +++ b/css/demo.css @@ -0,0 +1,63 @@ +/* + * JavaScript MD5 Demo CSS 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 + */ + +body { + max-width: 750px; + margin: 0 auto; + padding: 1em; + font-family: 'Lucida Grande', 'Lucida Sans Unicode', Arial, sans-serif; + font-size: 1em; + line-height: 1.4em; + background: #222; + color: #fff; + -webkit-text-size-adjust: 100%; + -ms-text-size-adjust: 100%; +} +a { + color: orange; + text-decoration: none; +} +img { + border: 0; + vertical-align: middle; +} +h1 { + line-height: 1em; +} +textarea, +input { + display: inline-block; + width: 100%; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + padding: 10px; + margin: 0 0 10px; +} + +@media (min-width: 481px) { + .navigation { + list-style: none; + padding: 0; + } + .navigation li { + display: inline-block; + } + .navigation li:not(:first-child):before { + content: '| '; + } +} + +/* IE7 fixes */ +*+html textarea, +*+html input { + width: 460px; +} diff --git a/index.html b/index.html index b63ec56..dfd72ae 100644 --- a/index.html +++ b/index.html @@ -1,7 +1,7 @@ - + JavaScript MD5 Demo - - - - - - + + - -
- -
-

JavaScript MD5 implementation.
- Compatible with server-side environments like node.js, module loaders like RequireJS and all web browsers.

-
+

JavaScript MD5 Demo

+

JavaScript MD5 implementation.
+Compatible with server-side environments like node.js, module loaders like RequireJS and all web browsers.

+ +
+

Input

+
-
-
-

Input

- -
-
-

Result

-
-

- - -

-
-
-
- - - - - + + +

Result

+ +
+ + + + + diff --git a/js/demo.js b/js/demo.js new file mode 100644 index 0000000..03373ba --- /dev/null +++ b/js/demo.js @@ -0,0 +1,23 @@ +/* + * 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(); + $('#result').val(window.md5($('#input').val())); + }); + $('#input').val('日本'); + +}); diff --git a/md5.js b/js/md5.js similarity index 99% rename from md5.js rename to js/md5.js index c4f4e8b..f92ba37 100644 --- a/md5.js +++ b/js/md5.js @@ -1,5 +1,5 @@ /* - * JavaScript MD5 1.0 + * JavaScript MD5 1.0.1 * https://github.com/blueimp/JavaScript-MD5 * * Copyright 2011, Sebastian Tschan @@ -64,7 +64,7 @@ */ function binl_md5(x, len) { /* append padding */ - x[len >> 5] |= 0x80 << ((len) % 32); + x[len >> 5] |= 0x80 << (len % 32); x[(((len + 64) >>> 9) << 4) + 14] = len; var i, olda, oldb, oldc, oldd, diff --git a/js/md5.min.js b/js/md5.min.js new file mode 100644 index 0000000..a571fa1 --- /dev/null +++ b/js/md5.min.js @@ -0,0 +1 @@ +!function(n){"use strict";function t(n,t){var r=(65535&n)+(65535&t),e=(n>>16)+(t>>16)+(r>>16);return e<<16|65535&r}function r(n,t){return n<>>32-t}function e(n,e,u,o,c,f){return t(r(t(t(e,n),t(o,f)),c),u)}function u(n,t,r,u,o,c,f){return e(t&r|~t&u,n,t,o,c,f)}function o(n,t,r,u,o,c,f){return e(t&u|r&~u,n,t,o,c,f)}function c(n,t,r,u,o,c,f){return e(t^r^u,n,t,o,c,f)}function f(n,t,r,u,o,c,f){return e(r^(t|~u),n,t,o,c,f)}function i(n,r){n[r>>5]|=128<>>9<<4)+14]=r;var e,i,a,h,d,g=1732584193,l=-271733879,v=-1732584194,C=271733878;for(e=0;e>5]>>>t%32);return r}function h(n){var t,r=[];for(r[(n.length>>2)-1]=void 0,t=0;t>5]|=(255&n.charCodeAt(t/8))<16&&(u=i(u,8*n.length)),r=0;16>r;r+=1)o[r]=909522486^u[r],c[r]=1549556828^u[r];return e=i(o.concat(h(t)),512+8*t.length),a(i(c.concat(e),640))}function l(n){var t,r,e="0123456789abcdef",u="";for(r=0;r>>4)+e.charAt(15&t);return u}function v(n){return unescape(encodeURIComponent(n))}function C(n){return d(v(n))}function m(n){return l(C(n))}function s(n,t){return g(v(n),v(t))}function A(n,t){return l(s(n,t))}function p(n,t,r){return t?r?s(t,n):A(t,n):r?C(n):m(n)}"function"==typeof define&&define.amd?define(function(){return p}):n.md5=p}(this); \ No newline at end of file diff --git a/md5.min.js b/md5.min.js deleted file mode 100644 index c8b38f2..0000000 --- a/md5.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(a){function b(a,b){var c=(a&65535)+(b&65535),d=(a>>16)+(b>>16)+(c>>16);return d<<16|c&65535}function c(a,b){return a<>>32-b}function d(a,d,e,f,g,h){return b(c(b(b(d,a),b(f,h)),g),e)}function e(a,b,c,e,f,g,h){return d(b&c|~b&e,a,b,f,g,h)}function f(a,b,c,e,f,g,h){return d(b&e|c&~e,a,b,f,g,h)}function g(a,b,c,e,f,g,h){return d(b^c^e,a,b,f,g,h)}function h(a,b,c,e,f,g,h){return d(c^(b|~e),a,b,f,g,h)}function i(a,c){a[c>>5]|=128<>>9<<4)+14]=c;var d,i,j,k,l,m=1732584193,n=-271733879,o=-1732584194,p=271733878;for(d=0;d>5]>>>b%32&255);return c}function k(a){var b,c=[];c[(a.length>>2)-1]=undefined;for(b=0;b>5]|=(a.charCodeAt(b/8)&255)<16&&(d=i(d,a.length*8));for(c=0;c<16;c+=1)e[c]=d[c]^909522486,f[c]=d[c]^1549556828;return g=i(e.concat(k(b)),512+b.length*8),j(i(f.concat(g),640))}function n(a){var b="0123456789abcdef",c="",d,e;for(e=0;e>>4&15)+b.charAt(d&15);return c}function o(a){return unescape(encodeURIComponent(a))}function p(a){return l(o(a))}function q(a){return n(p(a))}function r(a,b){return m(o(a),o(b))}function s(a,b){return n(r(a,b))}function t(a,b,c){return b?c?r(b,a):s(b,a):c?p(a):q(a)}"use strict",typeof define=="function"&&define.amd?define(function(){return t}):a.md5=t})(this); \ No newline at end of file diff --git a/package.json b/package.json index 8af292c..819935b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blueimp-md5", - "version": "1.0.0", + "version": "1.0.1", "title": "JavaScript MD5", "description": "JavaScript MD5 implementation.", "keywords": [ @@ -36,11 +36,12 @@ } ], "devDependencies": { - "mocha": "latest", - "expect.js": "latest" + "mocha": "1.11.0", + "expect.js": "0.2.0", + "uglify-js": "2.3.6" }, "scripts": { "test": "mocha --reporter spec" }, - "main": "md5.js" + "main": "js/md5.js" } diff --git a/test/index.html b/test/index.html index eb65380..abdf5a9 100644 --- a/test/index.html +++ b/test/index.html @@ -1,7 +1,7 @@ - + JavaScript MD5 Test - - + +
- - + + - + diff --git a/test/test.js b/test/test.js index 38e7f3c..135773c 100644 --- a/test/test.js +++ b/test/test.js @@ -1,5 +1,5 @@ /* - * JavaScript MD5 Test 1.0 + * JavaScript MD5 Test 1.0.1 * https://github.com/blueimp/JavaScript-MD5 * * Copyright 2011, Sebastian Tschan @@ -96,5 +96,5 @@ }( this.expect || require('expect.js'), - this.md5 || require('../md5').md5 + this.md5 || require('../js/md5').md5 )); From 89162fecbf0e0efce473e40c3dc685b6226656fa Mon Sep 17 00:00:00 2001 From: Sebastian Tschan Date: Wed, 26 Jun 2013 16:45:14 -0500 Subject: [PATCH 02/80] Fixed comment. --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index dfd72ae..e6c44f9 100644 --- a/index.html +++ b/index.html @@ -44,7 +44,7 @@

Result


- + From b84e37f2574f57be6b06d9690da865b6546b4d76 Mon Sep 17 00:00:00 2001 From: Sebastian Tschan Date: Wed, 26 Jun 2013 17:21:52 -0500 Subject: [PATCH 03/80] Updated jQuery version used for the tests. --- test/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/index.html b/test/index.html index abdf5a9..29ff520 100644 --- a/test/index.html +++ b/test/index.html @@ -23,7 +23,7 @@
- + + - + diff --git a/js/demo.js b/js/demo.js index 03373ba..96565d3 100644 --- a/js/demo.js +++ b/js/demo.js @@ -1,5 +1,5 @@ /* - * JavaScript MD5 Demo JS 1.0.1 + * JavaScript MD5 Demo JS * https://github.com/blueimp/JavaScript-MD5 * * Copyright 2013, Sebastian Tschan diff --git a/js/md5.js b/js/md5.js index f92ba37..d61eaf3 100644 --- a/js/md5.js +++ b/js/md5.js @@ -1,5 +1,5 @@ /* - * JavaScript MD5 1.0.1 + * JavaScript MD5 * https://github.com/blueimp/JavaScript-MD5 * * Copyright 2011, Sebastian Tschan @@ -7,7 +7,7 @@ * * Licensed under the MIT license: * http://www.opensource.org/licenses/MIT - * + * * Based on * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message * Digest Algorithm, as defined in RFC 1321. diff --git a/js/md5.min.js b/js/md5.min.js index 11b1545..ce09ed2 100644 --- a/js/md5.min.js +++ b/js/md5.min.js @@ -1 +1 @@ -!function(a){"use strict";function b(a,b){var c=(65535&a)+(65535&b),d=(a>>16)+(b>>16)+(c>>16);return d<<16|65535&c}function c(a,b){return a<>>32-b}function d(a,d,e,f,g,h){return b(c(b(b(d,a),b(f,h)),g),e)}function e(a,b,c,e,f,g,h){return d(b&c|~b&e,a,b,f,g,h)}function f(a,b,c,e,f,g,h){return d(b&e|c&~e,a,b,f,g,h)}function g(a,b,c,e,f,g,h){return d(b^c^e,a,b,f,g,h)}function h(a,b,c,e,f,g,h){return d(c^(b|~e),a,b,f,g,h)}function i(a,c){a[c>>5]|=128<>>9<<4)+14]=c;var d,i,j,k,l,m=1732584193,n=-271733879,o=-1732584194,p=271733878;for(d=0;d>5]>>>b%32&255);return c}function k(a){var b,c=[];for(c[(a.length>>2)-1]=void 0,b=0;b>5]|=(255&a.charCodeAt(b/8))<16&&(e=i(e,8*a.length)),c=0;16>c;c+=1)f[c]=909522486^e[c],g[c]=1549556828^e[c];return d=i(f.concat(k(b)),512+8*b.length),j(i(g.concat(d),640))}function n(a){var b,c,d="0123456789abcdef",e="";for(c=0;c>>4&15)+d.charAt(15&b);return e}function o(a){return unescape(encodeURIComponent(a))}function p(a){return l(o(a))}function q(a){return n(p(a))}function r(a,b){return m(o(a),o(b))}function s(a,b){return n(r(a,b))}function t(a,b,c){return b?c?r(b,a):s(b,a):c?p(a):q(a)}"function"==typeof define&&define.amd?define(function(){return t}):a.md5=t}(this); \ No newline at end of file +!function(n){"use strict";function t(n,t){var r=(65535&n)+(65535&t),e=(n>>16)+(t>>16)+(r>>16);return e<<16|65535&r}function r(n,t){return n<>>32-t}function e(n,e,u,o,c,f){return t(r(t(t(e,n),t(o,f)),c),u)}function u(n,t,r,u,o,c,f){return e(t&r|~t&u,n,t,o,c,f)}function o(n,t,r,u,o,c,f){return e(t&u|r&~u,n,t,o,c,f)}function c(n,t,r,u,o,c,f){return e(t^r^u,n,t,o,c,f)}function f(n,t,r,u,o,c,f){return e(r^(t|~u),n,t,o,c,f)}function i(n,r){n[r>>5]|=128<>>9<<4)+14]=r;var e,i,a,h,d,g=1732584193,l=-271733879,v=-1732584194,C=271733878;for(e=0;e>5]>>>t%32&255);return r}function h(n){var t,r=[];for(r[(n.length>>2)-1]=void 0,t=0;t>5]|=(255&n.charCodeAt(t/8))<16&&(u=i(u,8*n.length)),r=0;16>r;r+=1)o[r]=909522486^u[r],c[r]=1549556828^u[r];return e=i(o.concat(h(t)),512+8*t.length),a(i(c.concat(e),640))}function l(n){var t,r,e="0123456789abcdef",u="";for(r=0;r>>4&15)+e.charAt(15&t);return u}function v(n){return unescape(encodeURIComponent(n))}function C(n){return d(v(n))}function m(n){return l(C(n))}function s(n,t){return g(v(n),v(t))}function A(n,t){return l(s(n,t))}function p(n,t,r){return t?r?s(t,n):A(t,n):r?C(n):m(n)}"function"==typeof define&&define.amd?define(function(){return p}):n.md5=p}(this); diff --git a/package.json b/package.json index a589dc3..aa50c82 100644 --- a/package.json +++ b/package.json @@ -31,15 +31,35 @@ "bugs": "https://github.com/blueimp/JavaScript-MD5/issues", "license": "MIT", "devDependencies": { - "grunt": "~0.4.1", - "grunt-contrib-uglify": "~0.2.7", - "grunt-contrib-jshint": "~0.7.1", - "grunt-bump-build-git": "~1.0.0", - "grunt-simple-mocha": "~0.4.0", - "expect.js": "0.2.0" + "expect.js": "0.3.1", + "jshint": "2.8.0", + "mocha": "2.3.4", + "uglify-js": "2.6.1" }, "scripts": { - "test": "grunt test" + "test": "jshint js test && mocha", + "build": "uglifyjs js/md5.js -c -m > js/md5.min.js", + "preversion": "npm test", + "version": "npm run build && git add -A js", + "postversion": "git push origin master --tags && npm publish" }, - "main": "js/md5.js" + "main": "js/md5.js", + "jshintConfig": { + "bitwise": true, + "curly": true, + "eqeqeq": true, + "forin": true, + "freeze": true, + "immed": true, + "latedef": true, + "newcap": true, + "noarg": true, + "noempty": true, + "nonbsp": true, + "nonew": true, + "quotmark": true, + "undef": true, + "unused": true, + "strict": true + } } diff --git a/test/index.html b/test/index.html index 2c06f4f..a8edd48 100644 --- a/test/index.html +++ b/test/index.html @@ -1,7 +1,7 @@ JavaScript MD5 Demo - +

JavaScript MD5 Demo

JavaScript MD5 implementation.
-Compatible with server-side environments like node.js, module loaders like RequireJS and all web browsers.

+Compatible with server-side environments like Node.js, module loaders like RequireJS, Browserify or webpack and all web browsers.