From 7fff4499fd915bcea3fa93b1aa8b35f4fe7a6027 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sun, 28 May 2017 00:38:50 +0200 Subject: add linting (and some initial fixes) --- node_modules/md5-o-matic/lib/md5omatic.js | 201 ++++++++++++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 node_modules/md5-o-matic/lib/md5omatic.js (limited to 'node_modules/md5-o-matic/lib') diff --git a/node_modules/md5-o-matic/lib/md5omatic.js b/node_modules/md5-o-matic/lib/md5omatic.js new file mode 100644 index 000000000..361047c14 --- /dev/null +++ b/node_modules/md5-o-matic/lib/md5omatic.js @@ -0,0 +1,201 @@ +"use strict"; + +/** + * Expose `md5omatic(str)`. + */ + +module.exports = md5omatic; + +/** + * Hash any string using message digest. + * + * @param {String} str + * @return {String} + * @api public + */ + +function md5omatic(str) { + var x = str2blks_MD5(str); + var a = 1732584193; + var b = -271733879; + var c = -1732584194; + var d = 271733878; + + for(var i=0; i>> 1) | (b >>> 1); + + return (msb31 << 1) | lsb; +} + +function bitXOR(a, b) +{ + var lsb = (a & 0x1) ^ (b & 0x1); + var msb31 = (a >>> 1) ^ (b >>> 1); + + return (msb31 << 1) | lsb; +} + +function bitAND(a, b) +{ + var lsb = (a & 0x1) & (b & 0x1); + var msb31 = (a >>> 1) & (b >>> 1); + + return (msb31 << 1) | lsb; +} + +function addme(x, y) +{ + var lsw = (x & 0xFFFF)+(y & 0xFFFF); + var msw = (x >> 16)+(y >> 16)+(lsw >> 16); + + return (msw << 16) | (lsw & 0xFFFF); +} + +function rhex(num) +{ + var str = ""; + var j; + + for(j=0; j<=3; j++) + str += hex_chr.charAt((num >> (j * 8 + 4)) & 0x0F) + hex_chr.charAt((num >> (j * 8)) & 0x0F); + + return str; +} + +function str2blks_MD5(str) +{ + var nblk = ((str.length + 8) >> 6) + 1; + var blks = new Array(nblk * 16); + var i; + + for(i=0; i> 2] |= str.charCodeAt(i) << (((str.length * 8 + i) % 4) * 8); + + blks[i >> 2] |= 0x80 << (((str.length * 8 + i) % 4) * 8); + + var l = str.length * 8; + blks[nblk * 16 - 2] = (l & 0xFF); + blks[nblk * 16 - 2] |= ((l >>> 8) & 0xFF) << 8; + blks[nblk * 16 - 2] |= ((l >>> 16) & 0xFF) << 16; + blks[nblk * 16 - 2] |= ((l >>> 24) & 0xFF) << 24; + + return blks; +} + +function rol(num, cnt) +{ + return (num << cnt) | (num >>> (32 - cnt)); +} + +function cmn(q, a, b, x, s, t) +{ + return addme(rol((addme(addme(a, q), addme(x, t))), s), b); +} + +function ff(a, b, c, d, x, s, t) +{ + return cmn(bitOR(bitAND(b, c), bitAND((~b), d)), a, b, x, s, t); +} + +function gg(a, b, c, d, x, s, t) +{ + return cmn(bitOR(bitAND(b, d), bitAND(c, (~d))), a, b, x, s, t); +} + +function hh(a, b, c, d, x, s, t) +{ + return cmn(bitXOR(bitXOR(b, c), d), a, b, x, s, t); +} + +function ii(a, b, c, d, x, s, t) +{ + return cmn(bitXOR(c, bitOR(b, (~d))), a, b, x, s, t); +} \ No newline at end of file -- cgit v1.2.3