Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jshashes

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jshashes - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

.editorconfig

2573

hashes.js
/**
* jsHashes - A fast and independent hashing library pure JavaScript implemented (ES3 compliant) for both server and client side
*
* @class Hashes
* @author Tomas Aparicio <tomas@rijndael-project.com>
* @license New BSD (see LICENSE file)
* @version 1.0.4
* jshashes - https://github.com/h2non/jshashes
* Released under the "New BSD" license
*
* Algorithms specification:
*
* MD5 <http://www.ietf.org/rfc/rfc1321.txt>
* RIPEMD-160 <http://homes.esat.kuleuven.be/~bosselae/ripemd160.html>
* SHA1 <http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf>
* SHA256 <http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf>
* SHA512 <http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf>
* HMAC <http://www.ietf.org/rfc/rfc2104.txt>
*
* MD5 - http://www.ietf.org/rfc/rfc1321.txt
* RIPEMD-160 - http://homes.esat.kuleuven.be/~bosselae/ripemd160.html
* SHA1 - http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf
* SHA256 - http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf
* SHA512 - http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf
* HMAC - http://www.ietf.org/rfc/rfc2104.txt
*/
(function(){
(function() {
var Hashes;
// private helper methods
function utf8Encode(str) {
var x, y, output = '', i = -1, l;
var x, y, output = '',
i = -1,
l;
if (str && str.length) {
l = str.length;
while ((i+=1) < l) {
while ((i += 1) < l) {
/* Decode utf-16 surrogate pairs */

@@ -33,20 +29,20 @@ x = str.charCodeAt(i);

if (0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF) {
x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF);
i += 1;
x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF);
i += 1;
}
/* Encode output as utf-8 */
if (x <= 0x7F) {
output += String.fromCharCode(x);
output += String.fromCharCode(x);
} else if (x <= 0x7FF) {
output += String.fromCharCode(0xC0 | ((x >>> 6 ) & 0x1F),
0x80 | ( x & 0x3F));
output += String.fromCharCode(0xC0 | ((x >>> 6) & 0x1F),
0x80 | (x & 0x3F));
} else if (x <= 0xFFFF) {
output += String.fromCharCode(0xE0 | ((x >>> 12) & 0x0F),
0x80 | ((x >>> 6 ) & 0x3F),
0x80 | ( x & 0x3F));
output += String.fromCharCode(0xE0 | ((x >>> 12) & 0x0F),
0x80 | ((x >>> 6) & 0x3F),
0x80 | (x & 0x3F));
} else if (x <= 0x1FFFFF) {
output += String.fromCharCode(0xF0 | ((x >>> 18) & 0x07),
0x80 | ((x >>> 12) & 0x3F),
0x80 | ((x >>> 6 ) & 0x3F),
0x80 | ( x & 0x3F));
output += String.fromCharCode(0xF0 | ((x >>> 18) & 0x07),
0x80 | ((x >>> 12) & 0x3F),
0x80 | ((x >>> 6) & 0x3F),
0x80 | (x & 0x3F));
}

@@ -57,27 +53,28 @@ }

}
function utf8Decode(str) {
var i, ac, c1, c2, c3, arr = [], l;
var i, ac, c1, c2, c3, arr = [],
l;
i = ac = c1 = c2 = c3 = 0;
if (str && str.length) {
l = str.length;
str += '';
while (i < l) {
c1 = str.charCodeAt(i);
ac += 1;
if (c1 < 128) {
arr[ac] = String.fromCharCode(c1);
i+=1;
} else if (c1 > 191 && c1 < 224) {
c2 = str.charCodeAt(i + 1);
arr[ac] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63));
i += 2;
} else {
c2 = str.charCodeAt(i + 1);
c3 = str.charCodeAt(i + 2);
arr[ac] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}
c1 = str.charCodeAt(i);
ac += 1;
if (c1 < 128) {
arr[ac] = String.fromCharCode(c1);
i += 1;
} else if (c1 > 191 && c1 < 224) {
c2 = str.charCodeAt(i + 1);
arr[ac] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63));
i += 2;
} else {
c2 = str.charCodeAt(i + 1);
c3 = str.charCodeAt(i + 2);
arr[ac] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}
}

@@ -92,5 +89,6 @@ }

*/
function safe_add(x, y) {
var lsw = (x & 0xFFFF) + (y & 0xFFFF),
msw = (x >> 16) + (y >> 16) + (lsw >> 16);
msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);

@@ -102,2 +100,3 @@ }

*/
function bit_rol(num, cnt) {

@@ -110,6 +109,9 @@ return (num << cnt) | (num >>> (32 - cnt));

*/
function rstr2hex(input, hexcase) {
var hex_tab = hexcase ? '0123456789ABCDEF' : '0123456789abcdef',
output = '', x, i = 0, l = input.length;
for (; i < l; i+=1) {
output = '',
x, i = 0,
l = input.length;
for (; i < l; i += 1) {
x = input.charCodeAt(i);

@@ -124,6 +126,8 @@ output += hex_tab.charAt((x >>> 4) & 0x0F) + hex_tab.charAt(x & 0x0F);

*/
function str2rstr_utf16le(input) {
var i, l = input.length, output = '';
for (i = 0; i < l; i+=1) {
output += String.fromCharCode( input.charCodeAt(i) & 0xFF, (input.charCodeAt(i) >>> 8) & 0xFF);
var i, l = input.length,
output = '';
for (i = 0; i < l; i += 1) {
output += String.fromCharCode(input.charCodeAt(i) & 0xFF, (input.charCodeAt(i) >>> 8) & 0xFF);
}

@@ -134,4 +138,5 @@ return output;

function str2rstr_utf16be(input) {
var i, l = input.length, output = '';
for (i = 0; i < l; i+=1) {
var i, l = input.length,
output = '';
for (i = 0; i < l; i += 1) {
output += String.fromCharCode((input.charCodeAt(i) >>> 8) & 0xFF, input.charCodeAt(i) & 0xFF);

@@ -145,6 +150,8 @@ }

*/
function binb2rstr(input) {
var i, l = input.length * 32, output = '';
var i, l = input.length * 32,
output = '';
for (i = 0; i < l; i += 8) {
output += String.fromCharCode((input[i>>5] >>> (24 - i % 32)) & 0xFF);
output += String.fromCharCode((input[i >> 5] >>> (24 - i % 32)) & 0xFF);
}

@@ -157,6 +164,8 @@ return output;

*/
function binl2rstr(input) {
var i, l = input.length * 32, output = '';
for (i = 0;i < l; i += 8) {
output += String.fromCharCode((input[i>>5] >>> (i % 32)) & 0xFF);
var i, l = input.length * 32,
output = '';
for (i = 0; i < l; i += 8) {
output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xFF);
}

@@ -170,43 +179,50 @@ return output;

*/
function rstr2binl(input) {
var i, l = input.length * 8, output = Array(input.length >> 2), lo = output.length;
for (i = 0; i < lo; i+=1) {
var i, l = input.length * 8,
output = Array(input.length >> 2),
lo = output.length;
for (i = 0; i < lo; i += 1) {
output[i] = 0;
}
for (i = 0; i < l; i += 8) {
output[i>>5] |= (input.charCodeAt(i / 8) & 0xFF) << (i%32);
output[i >> 5] |= (input.charCodeAt(i / 8) & 0xFF) << (i % 32);
}
return output;
}
/**
* Convert a raw string to an array of big-endian words
* Convert a raw string to an array of big-endian words
* Characters >255 have their high-byte silently ignored.
*/
function rstr2binb(input) {
var i, l = input.length * 8, output = Array(input.length >> 2), lo = output.length;
for (i = 0; i < lo; i+=1) {
output[i] = 0;
}
for (i = 0; i < l; i += 8) {
output[i>>5] |= (input.charCodeAt(i / 8) & 0xFF) << (24 - i % 32);
}
return output;
}
function rstr2binb(input) {
var i, l = input.length * 8,
output = Array(input.length >> 2),
lo = output.length;
for (i = 0; i < lo; i += 1) {
output[i] = 0;
}
for (i = 0; i < l; i += 8) {
output[i >> 5] |= (input.charCodeAt(i / 8) & 0xFF) << (24 - i % 32);
}
return output;
}
/**
* Convert a raw string to an arbitrary string encoding
*/
function rstr2any(input, encoding) {
var divisor = encoding.length,
remainders = Array(),
i, q, x, ld, quotient, dividend, output, full_length;
remainders = Array(),
i, q, x, ld, quotient, dividend, output, full_length;
/* Convert to an array of 16-bit big-endian values, forming the dividend */
dividend = Array(Math.ceil(input.length / 2));
ld = dividend.length;
for (i = 0; i < ld; i+=1) {
for (i = 0; i < ld; i += 1) {
dividend[i] = (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1);
}
/**

@@ -218,6 +234,6 @@ * Repeatedly perform a long division. The binary array forms the dividend,

*/
while(dividend.length > 0) {
while (dividend.length > 0) {
quotient = Array();
x = 0;
for (i = 0; i < dividend.length; i+=1) {
for (i = 0; i < dividend.length; i += 1) {
x = (x << 16) + dividend[i];

@@ -233,3 +249,3 @@ q = Math.floor(x / divisor);

}
/* Convert the remainders to the output string */

@@ -240,6 +256,6 @@ output = '';

}
/* Append leading zero equivalents */
full_length = Math.ceil(input.length * 8 / (Math.log(encoding.length) / Math.log(2)));
for (i = output.length; i < full_length; i+=1) {
for (i = output.length; i < full_length; i += 1) {
output = encoding[0] + output;

@@ -253,18 +269,18 @@ }

*/
function rstr2b64(input, b64pad) {
var tab = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
output = '',
len = input.length, i, j, triplet;
b64pad= b64pad || '=';
output = '',
len = input.length,
i, j, triplet;
b64pad = b64pad || '=';
for (i = 0; i < len; i += 3) {
triplet = (input.charCodeAt(i) << 16)
| (i + 1 < len ? input.charCodeAt(i+1) << 8 : 0)
| (i + 2 < len ? input.charCodeAt(i+2) : 0);
for (j = 0; j < 4; j+=1) {
if (i * 8 + j * 6 > input.length * 8) {
output += b64pad;
} else {
output += tab.charAt((triplet >>> 6*(3-j)) & 0x3F);
triplet = (input.charCodeAt(i) << 16) | (i + 1 < len ? input.charCodeAt(i + 1) << 8 : 0) | (i + 2 < len ? input.charCodeAt(i + 2) : 0);
for (j = 0; j < 4; j += 1) {
if (i * 8 + j * 6 > input.length * 8) {
output += b64pad;
} else {
output += tab.charAt((triplet >>> 6 * (3 - j)) & 0x3F);
}
}
}
}

@@ -275,15 +291,15 @@ return output;

Hashes = {
/**
* @property {String} version
* @readonly
*/
VERSION : '1.0.3',
/**
* @member Hashes
* @class Base64
* @constructor
*/
Base64 : function () {
// private properties
var tab = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
/**
* @property {String} version
* @readonly
*/
VERSION: '1.0.5',
/**
* @member Hashes
* @class Base64
* @constructor
*/
Base64: function() {
// private properties
var tab = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
pad = '=', // default pad according with the RFC standard

@@ -293,77 +309,77 @@ url = false, // URL encoding support @todo

// public method for encoding
this.encode = function (input) {
var i, j, triplet,
output = '',
// public method for encoding
this.encode = function(input) {
var i, j, triplet,
output = '',
len = input.length;
pad = pad || '=';
input = (utf8) ? utf8Encode(input) : input;
pad = pad || '=';
input = (utf8) ? utf8Encode(input) : input;
for (i = 0; i < len; i += 3) {
triplet = (input.charCodeAt(i) << 16)
| (i + 1 < len ? input.charCodeAt(i+1) << 8 : 0)
| (i + 2 < len ? input.charCodeAt(i+2) : 0);
for (j = 0; j < 4; j+=1) {
if (i * 8 + j * 6 > len * 8) {
for (i = 0; i < len; i += 3) {
triplet = (input.charCodeAt(i) << 16) | (i + 1 < len ? input.charCodeAt(i + 1) << 8 : 0) | (i + 2 < len ? input.charCodeAt(i + 2) : 0);
for (j = 0; j < 4; j += 1) {
if (i * 8 + j * 6 > len * 8) {
output += pad;
} else {
output += tab.charAt((triplet >>> 6*(3-j)) & 0x3F);
} else {
output += tab.charAt((triplet >>> 6 * (3 - j)) & 0x3F);
}
}
}
}
return output;
};
return output;
};
// public method for decoding
this.decode = function (input) {
// var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
var i, o1, o2, o3, h1, h2, h3, h4, bits, ac,
dec = '',
arr = [];
if (!input) { return input; }
// public method for decoding
this.decode = function(input) {
// var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
var i, o1, o2, o3, h1, h2, h3, h4, bits, ac,
dec = '',
arr = [];
if (!input) {
return input;
}
i = ac = 0;
input = input.replace(new RegExp('\\'+pad,'gi'),''); // use '='
//input += '';
i = ac = 0;
input = input.replace(new RegExp('\\' + pad, 'gi'), ''); // use '='
//input += '';
do { // unpack four hexets into three octets using index points in b64
h1 = tab.indexOf(input.charAt(i+=1));
h2 = tab.indexOf(input.charAt(i+=1));
h3 = tab.indexOf(input.charAt(i+=1));
h4 = tab.indexOf(input.charAt(i+=1));
do { // unpack four hexets into three octets using index points in b64
h1 = tab.indexOf(input.charAt(i += 1));
h2 = tab.indexOf(input.charAt(i += 1));
h3 = tab.indexOf(input.charAt(i += 1));
h4 = tab.indexOf(input.charAt(i += 1));
bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;
bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;
o1 = bits >> 16 & 0xff;
o2 = bits >> 8 & 0xff;
o3 = bits & 0xff;
ac += 1;
o1 = bits >> 16 & 0xff;
o2 = bits >> 8 & 0xff;
o3 = bits & 0xff;
ac += 1;
if (h3 === 64) {
arr[ac] = String.fromCharCode(o1);
} else if (h4 === 64) {
arr[ac] = String.fromCharCode(o1, o2);
} else {
arr[ac] = String.fromCharCode(o1, o2, o3);
}
} while (i < input.length);
if (h3 === 64) {
arr[ac] = String.fromCharCode(o1);
} else if (h4 === 64) {
arr[ac] = String.fromCharCode(o1, o2);
} else {
arr[ac] = String.fromCharCode(o1, o2, o3);
}
} while (i < input.length);
dec = arr.join('');
dec = (utf8) ? utf8Decode(dec) : dec;
dec = arr.join('');
dec = (utf8) ? utf8Decode(dec) : dec;
return dec;
};
return dec;
};
// set custom pad string
this.setPad = function (str) {
// set custom pad string
this.setPad = function(str) {
pad = str || pad;
return this;
};
// set custom tab string characters
this.setTab = function (str) {
};
// set custom tab string characters
this.setTab = function(str) {
tab = str || tab;
return this;
};
this.setUTF8 = function (bool) {
};
this.setUTF8 = function(bool) {
if (typeof bool === 'boolean') {

@@ -373,18 +389,21 @@ utf8 = bool;

return this;
};
},
};
},
/**
* CRC-32 calculation
* @member Hashes
* @method CRC32
* @static
* @param {String} str Input String
* @return {String}
*/
CRC32 : function (str) {
var crc = 0, x = 0, y = 0, table, i, iTop;
str = utf8Encode(str);
table = [
/**
* CRC-32 calculation
* @member Hashes
* @method CRC32
* @static
* @param {String} str Input String
* @return {String}
*/
CRC32: function(str) {
var crc = 0,
x = 0,
y = 0,
table, i, iTop;
str = utf8Encode(str);
table = [
'00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 ',

@@ -407,3 +426,3 @@ '79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 ',

'60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA ',
'AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 ',
'AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 ',
'5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 ',

@@ -417,743 +436,820 @@ 'B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 ',

'C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D'
].join('');
].join('');
crc = crc ^ (-1);
for (i = 0, iTop = str.length; i < iTop; i+=1 ) {
y = ( crc ^ str.charCodeAt( i ) ) & 0xFF;
x = '0x' + table.substr( y * 9, 8 );
crc = ( crc >>> 8 ) ^ x;
}
// always return a positive number (that's what >>> 0 does)
return (crc ^ (-1)) >>> 0;
},
/**
* @member Hashes
* @class MD5
* @constructor
* @param {Object} [config]
*
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
* Digest Algorithm, as defined in RFC 1321.
* Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* See <http://pajhome.org.uk/crypt/md5> for more infHashes.
*/
MD5 : function (options) {
crc = crc ^ (-1);
for (i = 0, iTop = str.length; i < iTop; i += 1) {
y = (crc ^ str.charCodeAt(i)) & 0xFF;
x = '0x' + table.substr(y * 9, 8);
crc = (crc >>> 8) ^ x;
}
// always return a positive number (that's what >>> 0 does)
return (crc ^ (-1)) >>> 0;
},
/**
* Private config properties. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
* See {@link Hashes.MD5#method-setUpperCase} and {@link Hashes.SHA1#method-setUpperCase}
* @member Hashes
* @class MD5
* @constructor
* @param {Object} [config]
*
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
* Digest Algorithm, as defined in RFC 1321.
* Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* See <http://pajhome.org.uk/crypt/md5> for more infHashes.
*/
var hexcase = (options && typeof options.uppercase === 'boolean') ? options.uppercase : false, // hexadecimal output case format. false - lowercase; true - uppercase
MD5: function(options) {
/**
* Private config properties. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
* See {@link Hashes.MD5#method-setUpperCase} and {@link Hashes.SHA1#method-setUpperCase}
*/
var hexcase = (options && typeof options.uppercase === 'boolean') ? options.uppercase : false, // hexadecimal output case format. false - lowercase; true - uppercase
b64pad = (options && typeof options.pad === 'string') ? options.pda : '=', // base-64 pad character. Defaults to '=' for strict RFC compliance
utf8 = (options && typeof options.utf8 === 'boolean') ? options.utf8 : true; // enable/disable utf8 encoding
// privileged (public) methods
this.hex = function (s) {
return rstr2hex(rstr(s, utf8), hexcase);
};
this.b64 = function (s) {
return rstr2b64(rstr(s), b64pad);
};
this.any = function(s, e) {
return rstr2any(rstr(s, utf8), e);
};
this.hex_hmac = function (k, d) {
return rstr2hex(rstr_hmac(k, d), hexcase);
};
this.b64_hmac = function (k, d) {
return rstr2b64(rstr_hmac(k,d), b64pad);
};
this.any_hmac = function (k, d, e) {
return rstr2any(rstr_hmac(k, d), e);
};
/**
* Perform a simple self-test to see if the VM is working
* @return {String} Hexadecimal hash sample
*/
this.vm_test = function () {
return hex('abc').toLowerCase() === '900150983cd24fb0d6963f7d28e17f72';
};
/**
* Enable/disable uppercase hexadecimal returned string
* @param {Boolean}
* @return {Object} this
*/
this.setUpperCase = function (a) {
if (typeof a === 'boolean' ) {
hexcase = a;
}
return this;
};
/**
* Defines a base64 pad string
* @param {String} Pad
* @return {Object} this
*/
this.setPad = function (a) {
b64pad = a || b64pad;
return this;
};
/**
* Defines a base64 pad string
* @param {Boolean}
* @return {Object} [this]
*/
this.setUTF8 = function (a) {
if (typeof a === 'boolean') {
utf8 = a;
}
return this;
};
// privileged (public) methods
this.hex = function(s) {
return rstr2hex(rstr(s, utf8), hexcase);
};
this.b64 = function(s) {
return rstr2b64(rstr(s), b64pad);
};
this.any = function(s, e) {
return rstr2any(rstr(s, utf8), e);
};
this.raw = function(s) {
return rstr(s, utf8);
};
this.hex_hmac = function(k, d) {
return rstr2hex(rstr_hmac(k, d), hexcase);
};
this.b64_hmac = function(k, d) {
return rstr2b64(rstr_hmac(k, d), b64pad);
};
this.any_hmac = function(k, d, e) {
return rstr2any(rstr_hmac(k, d), e);
};
/**
* Perform a simple self-test to see if the VM is working
* @return {String} Hexadecimal hash sample
*/
this.vm_test = function() {
return hex('abc').toLowerCase() === '900150983cd24fb0d6963f7d28e17f72';
};
/**
* Enable/disable uppercase hexadecimal returned string
* @param {Boolean}
* @return {Object} this
*/
this.setUpperCase = function(a) {
if (typeof a === 'boolean') {
hexcase = a;
}
return this;
};
/**
* Defines a base64 pad string
* @param {String} Pad
* @return {Object} this
*/
this.setPad = function(a) {
b64pad = a || b64pad;
return this;
};
/**
* Defines a base64 pad string
* @param {Boolean}
* @return {Object} [this]
*/
this.setUTF8 = function(a) {
if (typeof a === 'boolean') {
utf8 = a;
}
return this;
};
// private methods
// private methods
/**
* Calculate the MD5 of a raw string
*/
function rstr(s) {
s = (utf8) ? utf8Encode(s): s;
return binl2rstr(binl(rstr2binl(s), s.length * 8));
}
/**
* Calculate the HMAC-MD5, of a key and some data (raw strings)
*/
function rstr_hmac(key, data) {
var bkey, ipad, opad, hash, i;
/**
* Calculate the MD5 of a raw string
*/
key = (utf8) ? utf8Encode(key) : key;
data = (utf8) ? utf8Encode(data) : data;
bkey = rstr2binl(key);
if (bkey.length > 16) {
bkey = binl(bkey, key.length * 8);
function rstr(s) {
s = (utf8) ? utf8Encode(s) : s;
return binl2rstr(binl(rstr2binl(s), s.length * 8));
}
ipad = Array(16), opad = Array(16);
for (i = 0; i < 16; i+=1) {
/**
* Calculate the HMAC-MD5, of a key and some data (raw strings)
*/
function rstr_hmac(key, data) {
var bkey, ipad, opad, hash, i;
key = (utf8) ? utf8Encode(key) : key;
data = (utf8) ? utf8Encode(data) : data;
bkey = rstr2binl(key);
if (bkey.length > 16) {
bkey = binl(bkey, key.length * 8);
}
ipad = Array(16), opad = Array(16);
for (i = 0; i < 16; i += 1) {
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
hash = binl(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
return binl2rstr(binl(opad.concat(hash), 512 + 128));
}
hash = binl(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
return binl2rstr(binl(opad.concat(hash), 512 + 128));
}
/**
* Calculate the MD5 of an array of little-endian words, and a bit length.
*/
function binl(x, len) {
var i, olda, oldb, oldc, oldd,
a = 1732584193,
/**
* Calculate the MD5 of an array of little-endian words, and a bit length.
*/
function binl(x, len) {
var i, olda, oldb, oldc, oldd,
a = 1732584193,
b = -271733879,
c = -1732584194,
d = 271733878;
/* append padding */
x[len >> 5] |= 0x80 << ((len) % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
d = 271733878;
for (i = 0; i < x.length; i += 16) {
olda = a;
oldb = b;
oldc = c;
oldd = d;
/* append padding */
x[len >> 5] |= 0x80 << ((len) % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
for (i = 0; i < x.length; i += 16) {
olda = a;
oldb = b;
oldc = c;
oldd = d;
a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936);
d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302);
a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222);
c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844);
d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
}
return Array(a, b, c, d);
}
return Array(a, b, c, d);
}
/**
* These functions implement the four basic operations the algorithm uses.
*/
function md5_cmn(q, a, b, x, s, t) {
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
}
function md5_ff(a, b, c, d, x, s, t) {
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function md5_gg(a, b, c, d, x, s, t) {
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function md5_hh(a, b, c, d, x, s, t) {
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t) {
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
},
/**
* @member Hashes
* @class Hashes.SHA1
* @param {Object} [config]
* @constructor
*
* A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined in FIPS 180-1
* Version 2.2 Copyright Paul Johnston 2000 - 2009.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* See http://pajhome.org.uk/crypt/md5 for details.
*/
SHA1 : function (options) {
/**
* Private config properties. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
* See {@link Hashes.MD5#method-setUpperCase} and {@link Hashes.SHA1#method-setUpperCase}
*/
var hexcase = (options && typeof options.uppercase === 'boolean') ? options.uppercase : false, // hexadecimal output case format. false - lowercase; true - uppercase
b64pad = (options && typeof options.pad === 'string') ? options.pda : '=', // base-64 pad character. Defaults to '=' for strict RFC compliance
utf8 = (options && typeof options.utf8 === 'boolean') ? options.utf8 : true; // enable/disable utf8 encoding
/**
* These functions implement the four basic operations the algorithm uses.
*/
// public methods
this.hex = function (s) {
return rstr2hex(rstr(s, utf8), hexcase);
};
this.b64 = function (s) {
return rstr2b64(rstr(s, utf8), b64pad);
};
this.any = function (s, e) {
return rstr2any(rstr(s, utf8), e);
};
this.hex_hmac = function (k, d) {
return rstr2hex(rstr_hmac(k, d));
};
this.b64_hmac = function (k, d) {
return rstr2b64(rstr_hmac(k, d), b64pad);
};
this.any_hmac = function (k, d, e) {
return rstr2any(rstr_hmac(k, d), e);
};
/**
* Perform a simple self-test to see if the VM is working
* @return {String} Hexadecimal hash sample
* @public
*/
this.vm_test = function () {
return hex('abc').toLowerCase() === '900150983cd24fb0d6963f7d28e17f72';
};
/**
* @description Enable/disable uppercase hexadecimal returned string
* @param {boolean}
* @return {Object} this
* @public
*/
this.setUpperCase = function (a) {
if (typeof a === 'boolean') {
hexcase = a;
function md5_cmn(q, a, b, x, s, t) {
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
}
return this;
};
/**
* @description Defines a base64 pad string
* @param {string} Pad
* @return {Object} this
* @public
*/
this.setPad = function (a) {
b64pad = a || b64pad;
return this;
};
/**
* @description Defines a base64 pad string
* @param {boolean}
* @return {Object} this
* @public
*/
this.setUTF8 = function (a) {
if (typeof a === 'boolean') {
utf8 = a;
function md5_ff(a, b, c, d, x, s, t) {
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
return this;
};
// private methods
function md5_gg(a, b, c, d, x, s, t) {
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
/**
* Calculate the SHA-512 of a raw string
*/
function rstr(s) {
s = (utf8) ? utf8Encode(s) : s;
return binb2rstr(binb(rstr2binb(s), s.length * 8));
}
function md5_hh(a, b, c, d, x, s, t) {
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t) {
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
},
/**
* Calculate the HMAC-SHA1 of a key and some data (raw strings)
* @member Hashes
* @class Hashes.SHA1
* @param {Object} [config]
* @constructor
*
* A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined in FIPS 180-1
* Version 2.2 Copyright Paul Johnston 2000 - 2009.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* See http://pajhome.org.uk/crypt/md5 for details.
*/
function rstr_hmac(key, data) {
var bkey, ipad, opad, i, hash;
key = (utf8) ? utf8Encode(key) : key;
data = (utf8) ? utf8Encode(data) : data;
bkey = rstr2binb(key);
SHA1: function(options) {
/**
* Private config properties. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
* See {@link Hashes.MD5#method-setUpperCase} and {@link Hashes.SHA1#method-setUpperCase}
*/
var hexcase = (options && typeof options.uppercase === 'boolean') ? options.uppercase : false, // hexadecimal output case format. false - lowercase; true - uppercase
b64pad = (options && typeof options.pad === 'string') ? options.pda : '=', // base-64 pad character. Defaults to '=' for strict RFC compliance
utf8 = (options && typeof options.utf8 === 'boolean') ? options.utf8 : true; // enable/disable utf8 encoding
if (bkey.length > 16) {
bkey = binb(bkey, key.length * 8);
// public methods
this.hex = function(s) {
return rstr2hex(rstr(s, utf8), hexcase);
};
this.b64 = function(s) {
return rstr2b64(rstr(s, utf8), b64pad);
};
this.any = function(s, e) {
return rstr2any(rstr(s, utf8), e);
};
this.raw = function(s) {
return rstr(s, utf8);
};
this.hex_hmac = function(k, d) {
return rstr2hex(rstr_hmac(k, d));
};
this.b64_hmac = function(k, d) {
return rstr2b64(rstr_hmac(k, d), b64pad);
};
this.any_hmac = function(k, d, e) {
return rstr2any(rstr_hmac(k, d), e);
};
/**
* Perform a simple self-test to see if the VM is working
* @return {String} Hexadecimal hash sample
* @public
*/
this.vm_test = function() {
return hex('abc').toLowerCase() === '900150983cd24fb0d6963f7d28e17f72';
};
/**
* @description Enable/disable uppercase hexadecimal returned string
* @param {boolean}
* @return {Object} this
* @public
*/
this.setUpperCase = function(a) {
if (typeof a === 'boolean') {
hexcase = a;
}
return this;
};
/**
* @description Defines a base64 pad string
* @param {string} Pad
* @return {Object} this
* @public
*/
this.setPad = function(a) {
b64pad = a || b64pad;
return this;
};
/**
* @description Defines a base64 pad string
* @param {boolean}
* @return {Object} this
* @public
*/
this.setUTF8 = function(a) {
if (typeof a === 'boolean') {
utf8 = a;
}
return this;
};
// private methods
/**
* Calculate the SHA-512 of a raw string
*/
function rstr(s) {
s = (utf8) ? utf8Encode(s) : s;
return binb2rstr(binb(rstr2binb(s), s.length * 8));
}
ipad = Array(16), opad = Array(16);
for (i = 0; i < 16; i+=1) {
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
hash = binb(ipad.concat(rstr2binb(data)), 512 + data.length * 8);
return binb2rstr(binb(opad.concat(hash), 512 + 160));
}
/**
* Calculate the SHA-1 of an array of big-endian words, and a bit length
*/
function binb(x, len) {
var i, j, t, olda, oldb, oldc, oldd, olde,
/**
* Calculate the HMAC-SHA1 of a key and some data (raw strings)
*/
function rstr_hmac(key, data) {
var bkey, ipad, opad, i, hash;
key = (utf8) ? utf8Encode(key) : key;
data = (utf8) ? utf8Encode(data) : data;
bkey = rstr2binb(key);
if (bkey.length > 16) {
bkey = binb(bkey, key.length * 8);
}
ipad = Array(16), opad = Array(16);
for (i = 0; i < 16; i += 1) {
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
hash = binb(ipad.concat(rstr2binb(data)), 512 + data.length * 8);
return binb2rstr(binb(opad.concat(hash), 512 + 160));
}
/**
* Calculate the SHA-1 of an array of big-endian words, and a bit length
*/
function binb(x, len) {
var i, j, t, olda, oldb, oldc, oldd, olde,
w = Array(80),
a = 1732584193,
a = 1732584193,
b = -271733879,
c = -1732584194,
d = 271733878,
d = 271733878,
e = -1009589776;
/* append padding */
x[len >> 5] |= 0x80 << (24 - len % 32);
x[((len + 64 >> 9) << 4) + 15] = len;
/* append padding */
x[len >> 5] |= 0x80 << (24 - len % 32);
x[((len + 64 >> 9) << 4) + 15] = len;
for (i = 0; i < x.length; i += 16) {
olda = a,
oldb = b;
oldc = c;
oldd = d;
olde = e;
for (j = 0; j < 80; j+=1) {
if (j < 16) {
w[j] = x[i + j];
} else {
w[j] = bit_rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
for (i = 0; i < x.length; i += 16) {
olda = a,
oldb = b;
oldc = c;
oldd = d;
olde = e;
for (j = 0; j < 80; j += 1) {
if (j < 16) {
w[j] = x[i + j];
} else {
w[j] = bit_rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
}
t = safe_add(safe_add(bit_rol(a, 5), sha1_ft(j, b, c, d)),
safe_add(safe_add(e, w[j]), sha1_kt(j)));
e = d;
d = c;
c = bit_rol(b, 30);
b = a;
a = t;
}
t = safe_add(safe_add(bit_rol(a, 5), sha1_ft(j, b, c, d)),
safe_add(safe_add(e, w[j]), sha1_kt(j)));
e = d;
d = c;
c = bit_rol(b, 30);
b = a;
a = t;
}
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
e = safe_add(e, olde);
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
e = safe_add(e, olde);
}
return Array(a, b, c, d, e);
}
return Array(a, b, c, d, e);
}
/**
* Perform the appropriate triplet combination function for the current
* iteration
*/
function sha1_ft(t, b, c, d) {
if (t < 20) { return (b & c) | ((~b) & d); }
if (t < 40) { return b ^ c ^ d; }
if (t < 60) { return (b & c) | (b & d) | (c & d); }
return b ^ c ^ d;
}
/**
* Perform the appropriate triplet combination function for the current
* iteration
*/
function sha1_ft(t, b, c, d) {
if (t < 20) {
return (b & c) | ((~b) & d);
}
if (t < 40) {
return b ^ c ^ d;
}
if (t < 60) {
return (b & c) | (b & d) | (c & d);
}
return b ^ c ^ d;
}
/**
* Determine the appropriate additive constant for the current iteration
*/
function sha1_kt(t) {
return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 :
(t < 60) ? -1894007588 : -899497514;
}
},
/**
* Determine the appropriate additive constant for the current iteration
* @class Hashes.SHA256
* @param {config}
*
* A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined in FIPS 180-2
* Version 2.2 Copyright Angel Marin, Paul Johnston 2000 - 2009.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* See http://pajhome.org.uk/crypt/md5 for details.
* Also http://anmar.eu.org/projects/jssha2/
*/
function sha1_kt(t) {
return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 :
(t < 60) ? -1894007588 : -899497514;
}
},
/**
* @class Hashes.SHA256
* @param {config}
*
* A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined in FIPS 180-2
* Version 2.2 Copyright Angel Marin, Paul Johnston 2000 - 2009.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* See http://pajhome.org.uk/crypt/md5 for details.
* Also http://anmar.eu.org/projects/jssha2/
*/
SHA256 : function (options) {
/**
* Private properties configuration variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
* @see this.setUpperCase() method
* @see this.setPad() method
*/
var hexcase = (options && typeof options.uppercase === 'boolean') ? options.uppercase : false, // hexadecimal output case format. false - lowercase; true - uppercase */
b64pad = (options && typeof options.pad === 'string') ? options.pda : '=', /* base-64 pad character. Default '=' for strict RFC compliance */
utf8 = (options && typeof options.utf8 === 'boolean') ? options.utf8 : true, /* enable/disable utf8 encoding */
sha256_K;
SHA256: function(options) {
/**
* Private properties configuration variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
* @see this.setUpperCase() method
* @see this.setPad() method
*/
var hexcase = (options && typeof options.uppercase === 'boolean') ? options.uppercase : false, // hexadecimal output case format. false - lowercase; true - uppercase */
b64pad = (options && typeof options.pad === 'string') ? options.pda : '=',
/* base-64 pad character. Default '=' for strict RFC compliance */
utf8 = (options && typeof options.utf8 === 'boolean') ? options.utf8 : true,
/* enable/disable utf8 encoding */
sha256_K;
/* privileged (public) methods */
this.hex = function (s) {
return rstr2hex(rstr(s, utf8));
};
this.b64 = function (s) {
return rstr2b64(rstr(s, utf8), b64pad);
};
this.any = function (s, e) {
return rstr2any(rstr(s, utf8), e);
};
this.hex_hmac = function (k, d) {
return rstr2hex(rstr_hmac(k, d));
};
this.b64_hmac = function (k, d) {
return rstr2b64(rstr_hmac(k, d), b64pad);
};
this.any_hmac = function (k, d, e) {
return rstr2any(rstr_hmac(k, d), e);
};
/**
* Perform a simple self-test to see if the VM is working
* @return {String} Hexadecimal hash sample
* @public
*/
this.vm_test = function () {
return hex('abc').toLowerCase() === '900150983cd24fb0d6963f7d28e17f72';
};
/**
* Enable/disable uppercase hexadecimal returned string
* @param {boolean}
* @return {Object} this
* @public
*/
this.setUpperCase = function (a) {
if (typeof a === 'boolean') {
hexcase = a;
/* privileged (public) methods */
this.hex = function(s) {
return rstr2hex(rstr(s, utf8));
};
this.b64 = function(s) {
return rstr2b64(rstr(s, utf8), b64pad);
};
this.any = function(s, e) {
return rstr2any(rstr(s, utf8), e);
};
this.raw = function(s) {
return rstr(s, utf8);
};
this.hex_hmac = function(k, d) {
return rstr2hex(rstr_hmac(k, d));
};
this.b64_hmac = function(k, d) {
return rstr2b64(rstr_hmac(k, d), b64pad);
};
this.any_hmac = function(k, d, e) {
return rstr2any(rstr_hmac(k, d), e);
};
/**
* Perform a simple self-test to see if the VM is working
* @return {String} Hexadecimal hash sample
* @public
*/
this.vm_test = function() {
return hex('abc').toLowerCase() === '900150983cd24fb0d6963f7d28e17f72';
};
/**
* Enable/disable uppercase hexadecimal returned string
* @param {boolean}
* @return {Object} this
* @public
*/
this.setUpperCase = function(a) {
if (typeof a === 'boolean') {
hexcase = a;
}
return this;
};
/**
* @description Defines a base64 pad string
* @param {string} Pad
* @return {Object} this
* @public
*/
this.setPad = function(a) {
b64pad = a || b64pad;
return this;
};
/**
* Defines a base64 pad string
* @param {boolean}
* @return {Object} this
* @public
*/
this.setUTF8 = function(a) {
if (typeof a === 'boolean') {
utf8 = a;
}
return this;
};
// private methods
/**
* Calculate the SHA-512 of a raw string
*/
function rstr(s, utf8) {
s = (utf8) ? utf8Encode(s) : s;
return binb2rstr(binb(rstr2binb(s), s.length * 8));
}
return this;
};
/**
* @description Defines a base64 pad string
* @param {string} Pad
* @return {Object} this
* @public
*/
this.setPad = function (a) {
b64pad = a || b64pad;
return this;
};
/**
* Defines a base64 pad string
* @param {boolean}
* @return {Object} this
* @public
*/
this.setUTF8 = function (a) {
if (typeof a === 'boolean') {
utf8 = a;
}
return this;
};
// private methods
/**
* Calculate the SHA-512 of a raw string
*/
function rstr(s, utf8) {
s = (utf8) ? utf8Encode(s) : s;
return binb2rstr(binb(rstr2binb(s), s.length * 8));
}
/**
* Calculate the HMAC-sha256 of a key and some data (raw strings)
*/
/**
* Calculate the HMAC-sha256 of a key and some data (raw strings)
*/
function rstr_hmac(key, data) {
key = (utf8) ? utf8Encode(key) : key;
data = (utf8) ? utf8Encode(data) : data;
var hash, i = 0,
bkey = rstr2binb(key),
ipad = Array(16),
function rstr_hmac(key, data) {
key = (utf8) ? utf8Encode(key) : key;
data = (utf8) ? utf8Encode(data) : data;
var hash, i = 0,
bkey = rstr2binb(key),
ipad = Array(16),
opad = Array(16);
if (bkey.length > 16) { bkey = binb(bkey, key.length * 8); }
for (; i < 16; i+=1) {
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
hash = binb(ipad.concat(rstr2binb(data)), 512 + data.length * 8);
return binb2rstr(binb(opad.concat(hash), 512 + 256));
}
/*
* Main sha256 function, with its support functions
*/
function sha256_S (X, n) {return ( X >>> n ) | (X << (32 - n));}
function sha256_R (X, n) {return ( X >>> n );}
function sha256_Ch(x, y, z) {return ((x & y) ^ ((~x) & z));}
function sha256_Maj(x, y, z) {return ((x & y) ^ (x & z) ^ (y & z));}
function sha256_Sigma0256(x) {return (sha256_S(x, 2) ^ sha256_S(x, 13) ^ sha256_S(x, 22));}
function sha256_Sigma1256(x) {return (sha256_S(x, 6) ^ sha256_S(x, 11) ^ sha256_S(x, 25));}
function sha256_Gamma0256(x) {return (sha256_S(x, 7) ^ sha256_S(x, 18) ^ sha256_R(x, 3));}
function sha256_Gamma1256(x) {return (sha256_S(x, 17) ^ sha256_S(x, 19) ^ sha256_R(x, 10));}
function sha256_Sigma0512(x) {return (sha256_S(x, 28) ^ sha256_S(x, 34) ^ sha256_S(x, 39));}
function sha256_Sigma1512(x) {return (sha256_S(x, 14) ^ sha256_S(x, 18) ^ sha256_S(x, 41));}
function sha256_Gamma0512(x) {return (sha256_S(x, 1) ^ sha256_S(x, 8) ^ sha256_R(x, 7));}
function sha256_Gamma1512(x) {return (sha256_S(x, 19) ^ sha256_S(x, 61) ^ sha256_R(x, 6));}
sha256_K = [
1116352408, 1899447441, -1245643825, -373957723, 961987163, 1508970993,
-1841331548, -1424204075, -670586216, 310598401, 607225278, 1426881987,
1925078388, -2132889090, -1680079193, -1046744716, -459576895, -272742522,
264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986,
-1740746414, -1473132947, -1341970488, -1084653625, -958395405, -710438585,
113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291,
1695183700, 1986661051, -2117940946, -1838011259, -1564481375, -1474664885,
-1035236496, -949202525, -778901479, -694614492, -200395387, 275423344,
430227734, 506948616, 659060556, 883997877, 958139571, 1322822218,
1537002063, 1747873779, 1955562222, 2024104815, -2067236844, -1933114872,
-1866530822, -1538233109, -1090935817, -965641998
];
function binb(m, l) {
var HASH = [1779033703, -1150833019, 1013904242, -1521486534,
1359893119, -1694144372, 528734635, 1541459225];
var W = new Array(64);
var a, b, c, d, e, f, g, h;
var i, j, T1, T2;
/* append padding */
m[l >> 5] |= 0x80 << (24 - l % 32);
m[((l + 64 >> 9) << 4) + 15] = l;
for (i = 0; i < m.length; i += 16)
{
a = HASH[0];
b = HASH[1];
c = HASH[2];
d = HASH[3];
e = HASH[4];
f = HASH[5];
g = HASH[6];
h = HASH[7];
for (j = 0; j < 64; j+=1)
{
if (j < 16) {
W[j] = m[j + i];
} else {
W[j] = safe_add(safe_add(safe_add(sha256_Gamma1256(W[j - 2]), W[j - 7]),
sha256_Gamma0256(W[j - 15])), W[j - 16]);
if (bkey.length > 16) {
bkey = binb(bkey, key.length * 8);
}
T1 = safe_add(safe_add(safe_add(safe_add(h, sha256_Sigma1256(e)), sha256_Ch(e, f, g)),
sha256_K[j]), W[j]);
T2 = safe_add(sha256_Sigma0256(a), sha256_Maj(a, b, c));
h = g;
g = f;
f = e;
e = safe_add(d, T1);
d = c;
c = b;
b = a;
a = safe_add(T1, T2);
for (; i < 16; i += 1) {
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
hash = binb(ipad.concat(rstr2binb(data)), 512 + data.length * 8);
return binb2rstr(binb(opad.concat(hash), 512 + 256));
}
HASH[0] = safe_add(a, HASH[0]);
HASH[1] = safe_add(b, HASH[1]);
HASH[2] = safe_add(c, HASH[2]);
HASH[3] = safe_add(d, HASH[3]);
HASH[4] = safe_add(e, HASH[4]);
HASH[5] = safe_add(f, HASH[5]);
HASH[6] = safe_add(g, HASH[6]);
HASH[7] = safe_add(h, HASH[7]);
/*
* Main sha256 function, with its support functions
*/
function sha256_S(X, n) {
return (X >>> n) | (X << (32 - n));
}
return HASH;
}
},
function sha256_R(X, n) {
return (X >>> n);
}
/**
* @class Hashes.SHA512
* @param {config}
*
* A JavaScript implementation of the Secure Hash Algorithm, SHA-512, as defined in FIPS 180-2
* Version 2.2 Copyright Anonymous Contributor, Paul Johnston 2000 - 2009.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* See http://pajhome.org.uk/crypt/md5 for details.
*/
SHA512 : function (options) {
function sha256_Ch(x, y, z) {
return ((x & y) ^ ((~x) & z));
}
function sha256_Maj(x, y, z) {
return ((x & y) ^ (x & z) ^ (y & z));
}
function sha256_Sigma0256(x) {
return (sha256_S(x, 2) ^ sha256_S(x, 13) ^ sha256_S(x, 22));
}
function sha256_Sigma1256(x) {
return (sha256_S(x, 6) ^ sha256_S(x, 11) ^ sha256_S(x, 25));
}
function sha256_Gamma0256(x) {
return (sha256_S(x, 7) ^ sha256_S(x, 18) ^ sha256_R(x, 3));
}
function sha256_Gamma1256(x) {
return (sha256_S(x, 17) ^ sha256_S(x, 19) ^ sha256_R(x, 10));
}
function sha256_Sigma0512(x) {
return (sha256_S(x, 28) ^ sha256_S(x, 34) ^ sha256_S(x, 39));
}
function sha256_Sigma1512(x) {
return (sha256_S(x, 14) ^ sha256_S(x, 18) ^ sha256_S(x, 41));
}
function sha256_Gamma0512(x) {
return (sha256_S(x, 1) ^ sha256_S(x, 8) ^ sha256_R(x, 7));
}
function sha256_Gamma1512(x) {
return (sha256_S(x, 19) ^ sha256_S(x, 61) ^ sha256_R(x, 6));
}
sha256_K = [
1116352408, 1899447441, -1245643825, -373957723, 961987163, 1508970993, -1841331548, -1424204075, -670586216, 310598401, 607225278, 1426881987,
1925078388, -2132889090, -1680079193, -1046744716, -459576895, -272742522,
264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, -1740746414, -1473132947, -1341970488, -1084653625, -958395405, -710438585,
113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291,
1695183700, 1986661051, -2117940946, -1838011259, -1564481375, -1474664885, -1035236496, -949202525, -778901479, -694614492, -200395387, 275423344,
430227734, 506948616, 659060556, 883997877, 958139571, 1322822218,
1537002063, 1747873779, 1955562222, 2024104815, -2067236844, -1933114872, -1866530822, -1538233109, -1090935817, -965641998
];
function binb(m, l) {
var HASH = [1779033703, -1150833019, 1013904242, -1521486534,
1359893119, -1694144372, 528734635, 1541459225
];
var W = new Array(64);
var a, b, c, d, e, f, g, h;
var i, j, T1, T2;
/* append padding */
m[l >> 5] |= 0x80 << (24 - l % 32);
m[((l + 64 >> 9) << 4) + 15] = l;
for (i = 0; i < m.length; i += 16) {
a = HASH[0];
b = HASH[1];
c = HASH[2];
d = HASH[3];
e = HASH[4];
f = HASH[5];
g = HASH[6];
h = HASH[7];
for (j = 0; j < 64; j += 1) {
if (j < 16) {
W[j] = m[j + i];
} else {
W[j] = safe_add(safe_add(safe_add(sha256_Gamma1256(W[j - 2]), W[j - 7]),
sha256_Gamma0256(W[j - 15])), W[j - 16]);
}
T1 = safe_add(safe_add(safe_add(safe_add(h, sha256_Sigma1256(e)), sha256_Ch(e, f, g)),
sha256_K[j]), W[j]);
T2 = safe_add(sha256_Sigma0256(a), sha256_Maj(a, b, c));
h = g;
g = f;
f = e;
e = safe_add(d, T1);
d = c;
c = b;
b = a;
a = safe_add(T1, T2);
}
HASH[0] = safe_add(a, HASH[0]);
HASH[1] = safe_add(b, HASH[1]);
HASH[2] = safe_add(c, HASH[2]);
HASH[3] = safe_add(d, HASH[3]);
HASH[4] = safe_add(e, HASH[4]);
HASH[5] = safe_add(f, HASH[5]);
HASH[6] = safe_add(g, HASH[6]);
HASH[7] = safe_add(h, HASH[7]);
}
return HASH;
}
},
/**
* Private properties configuration variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
* @see this.setUpperCase() method
* @see this.setPad() method
* @class Hashes.SHA512
* @param {config}
*
* A JavaScript implementation of the Secure Hash Algorithm, SHA-512, as defined in FIPS 180-2
* Version 2.2 Copyright Anonymous Contributor, Paul Johnston 2000 - 2009.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* See http://pajhome.org.uk/crypt/md5 for details.
*/
var hexcase = (options && typeof options.uppercase === 'boolean') ? options.uppercase : false , /* hexadecimal output case format. false - lowercase; true - uppercase */
b64pad = (options && typeof options.pad === 'string') ? options.pda : '=', /* base-64 pad character. Default '=' for strict RFC compliance */
utf8 = (options && typeof options.utf8 === 'boolean') ? options.utf8 : true, /* enable/disable utf8 encoding */
SHA512: function(options) {
/**
* Private properties configuration variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
* @see this.setUpperCase() method
* @see this.setPad() method
*/
var hexcase = (options && typeof options.uppercase === 'boolean') ? options.uppercase : false,
/* hexadecimal output case format. false - lowercase; true - uppercase */
b64pad = (options && typeof options.pad === 'string') ? options.pda : '=',
/* base-64 pad character. Default '=' for strict RFC compliance */
utf8 = (options && typeof options.utf8 === 'boolean') ? options.utf8 : true,
/* enable/disable utf8 encoding */
sha512_k;
/* privileged (public) methods */
this.hex = function (s) {
return rstr2hex(rstr(s));
};
this.b64 = function (s) {
return rstr2b64(rstr(s), b64pad);
};
this.any = function (s, e) {
return rstr2any(rstr(s), e);
};
this.hex_hmac = function (k, d) {
return rstr2hex(rstr_hmac(k, d));
};
this.b64_hmac = function (k, d) {
return rstr2b64(rstr_hmac(k, d), b64pad);
};
this.any_hmac = function (k, d, e) {
return rstr2any(rstr_hmac(k, d), e);
};
/**
* Perform a simple self-test to see if the VM is working
* @return {String} Hexadecimal hash sample
* @public
*/
this.vm_test = function () {
return hex('abc').toLowerCase() === '900150983cd24fb0d6963f7d28e17f72';
};
/**
* @description Enable/disable uppercase hexadecimal returned string
* @param {boolean}
* @return {Object} this
* @public
*/
this.setUpperCase = function (a) {
if (typeof a === 'boolean') {
hexcase = a;
/* privileged (public) methods */
this.hex = function(s) {
return rstr2hex(rstr(s));
};
this.b64 = function(s) {
return rstr2b64(rstr(s), b64pad);
};
this.any = function(s, e) {
return rstr2any(rstr(s), e);
};
this.raw = function(s) {
return rstr(s, utf8);
};
this.hex_hmac = function(k, d) {
return rstr2hex(rstr_hmac(k, d));
};
this.b64_hmac = function(k, d) {
return rstr2b64(rstr_hmac(k, d), b64pad);
};
this.any_hmac = function(k, d, e) {
return rstr2any(rstr_hmac(k, d), e);
};
/**
* Perform a simple self-test to see if the VM is working
* @return {String} Hexadecimal hash sample
* @public
*/
this.vm_test = function() {
return hex('abc').toLowerCase() === '900150983cd24fb0d6963f7d28e17f72';
};
/**
* @description Enable/disable uppercase hexadecimal returned string
* @param {boolean}
* @return {Object} this
* @public
*/
this.setUpperCase = function(a) {
if (typeof a === 'boolean') {
hexcase = a;
}
return this;
};
/**
* @description Defines a base64 pad string
* @param {string} Pad
* @return {Object} this
* @public
*/
this.setPad = function(a) {
b64pad = a || b64pad;
return this;
};
/**
* @description Defines a base64 pad string
* @param {boolean}
* @return {Object} this
* @public
*/
this.setUTF8 = function(a) {
if (typeof a === 'boolean') {
utf8 = a;
}
return this;
};
/* private methods */
/**
* Calculate the SHA-512 of a raw string
*/
function rstr(s) {
s = (utf8) ? utf8Encode(s) : s;
return binb2rstr(binb(rstr2binb(s), s.length * 8));
}
return this;
};
/**
* @description Defines a base64 pad string
* @param {string} Pad
* @return {Object} this
* @public
*/
this.setPad = function (a) {
b64pad = a || b64pad;
return this;
};
/**
* @description Defines a base64 pad string
* @param {boolean}
* @return {Object} this
* @public
*/
this.setUTF8 = function (a) {
if (typeof a === 'boolean') {
utf8 = a;
}
return this;
};
/*
* Calculate the HMAC-SHA-512 of a key and some data (raw strings)
*/
/* private methods */
/**
* Calculate the SHA-512 of a raw string
*/
function rstr(s) {
s = (utf8) ? utf8Encode(s) : s;
return binb2rstr(binb(rstr2binb(s), s.length * 8));
}
/*
* Calculate the HMAC-SHA-512 of a key and some data (raw strings)
*/
function rstr_hmac(key, data) {
key = (utf8) ? utf8Encode(key) : key;
data = (utf8) ? utf8Encode(data) : data;
var hash, i = 0,
function rstr_hmac(key, data) {
key = (utf8) ? utf8Encode(key) : key;
data = (utf8) ? utf8Encode(data) : data;
var hash, i = 0,
bkey = rstr2binb(key),
ipad = Array(32), opad = Array(32);
ipad = Array(32),
opad = Array(32);
if (bkey.length > 32) { bkey = binb(bkey, key.length * 8); }
for (; i < 32; i+=1) {
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
if (bkey.length > 32) {
bkey = binb(bkey, key.length * 8);
}
for (; i < 32; i += 1) {
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
hash = binb(ipad.concat(rstr2binb(data)), 1024 + data.length * 8);
return binb2rstr(binb(opad.concat(hash), 1024 + 512));
}
hash = binb(ipad.concat(rstr2binb(data)), 1024 + data.length * 8);
return binb2rstr(binb(opad.concat(hash), 1024 + 512));
}
/**
* Calculate the SHA-512 of an array of big-endian dwords, and a bit length
*/
function binb(x, len) {
var j, i, l,
/**
* Calculate the SHA-512 of an array of big-endian dwords, and a bit length
*/
function binb(x, len) {
var j, i, l,
W = new Array(80),

@@ -1174,10 +1270,10 @@ hash = new Array(16),

T2 = new int64(0, 0),
a = new int64(0,0),
b = new int64(0,0),
c = new int64(0,0),
d = new int64(0,0),
e = new int64(0,0),
f = new int64(0,0),
g = new int64(0,0),
h = new int64(0,0),
a = new int64(0, 0),
b = new int64(0, 0),
c = new int64(0, 0),
d = new int64(0, 0),
e = new int64(0, 0),
f = new int64(0, 0),
g = new int64(0, 0),
h = new int64(0, 0),
//Temporary variables not specified by the document

@@ -1192,3 +1288,3 @@ s0 = new int64(0, 0),

if (sha512_k === undefined) {
if (sha512_k === undefined) {
//SHA512 constants

@@ -1237,319 +1333,345 @@ sha512_k = [

];
}
for (i=0; i<80; i+=1) {
W[i] = new int64(0, 0);
}
// append padding to the source string. The format is described in the FIPS.
x[len >> 5] |= 0x80 << (24 - (len & 0x1f));
x[((len + 128 >> 10)<< 5) + 31] = len;
l = x.length;
for (i = 0; i<l; i+=32) { //32 dwords is the block size
int64copy(a, H[0]);
int64copy(b, H[1]);
int64copy(c, H[2]);
int64copy(d, H[3]);
int64copy(e, H[4]);
int64copy(f, H[5]);
int64copy(g, H[6]);
int64copy(h, H[7]);
for (j=0; j<16; j+=1) {
W[j].h = x[i + 2*j];
W[j].l = x[i + 2*j + 1];
}
for (j=16; j<80; j+=1) {
//sigma1
int64rrot(r1, W[j-2], 19);
int64revrrot(r2, W[j-2], 29);
int64shr(r3, W[j-2], 6);
s1.l = r1.l ^ r2.l ^ r3.l;
s1.h = r1.h ^ r2.h ^ r3.h;
//sigma0
int64rrot(r1, W[j-15], 1);
int64rrot(r2, W[j-15], 8);
int64shr(r3, W[j-15], 7);
s0.l = r1.l ^ r2.l ^ r3.l;
s0.h = r1.h ^ r2.h ^ r3.h;
int64add4(W[j], s1, W[j-7], s0, W[j-16]);
for (i = 0; i < 80; i += 1) {
W[i] = new int64(0, 0);
}
for (j = 0; j < 80; j+=1) {
//Ch
Ch.l = (e.l & f.l) ^ (~e.l & g.l);
Ch.h = (e.h & f.h) ^ (~e.h & g.h);
//Sigma1
int64rrot(r1, e, 14);
int64rrot(r2, e, 18);
int64revrrot(r3, e, 9);
s1.l = r1.l ^ r2.l ^ r3.l;
s1.h = r1.h ^ r2.h ^ r3.h;
//Sigma0
int64rrot(r1, a, 28);
int64revrrot(r2, a, 2);
int64revrrot(r3, a, 7);
s0.l = r1.l ^ r2.l ^ r3.l;
s0.h = r1.h ^ r2.h ^ r3.h;
//Maj
Maj.l = (a.l & b.l) ^ (a.l & c.l) ^ (b.l & c.l);
Maj.h = (a.h & b.h) ^ (a.h & c.h) ^ (b.h & c.h);
int64add5(T1, h, s1, Ch, sha512_k[j], W[j]);
int64add(T2, s0, Maj);
int64copy(h, g);
int64copy(g, f);
int64copy(f, e);
int64add(e, d, T1);
int64copy(d, c);
int64copy(c, b);
int64copy(b, a);
int64add(a, T1, T2);
// append padding to the source string. The format is described in the FIPS.
x[len >> 5] |= 0x80 << (24 - (len & 0x1f));
x[((len + 128 >> 10) << 5) + 31] = len;
l = x.length;
for (i = 0; i < l; i += 32) { //32 dwords is the block size
int64copy(a, H[0]);
int64copy(b, H[1]);
int64copy(c, H[2]);
int64copy(d, H[3]);
int64copy(e, H[4]);
int64copy(f, H[5]);
int64copy(g, H[6]);
int64copy(h, H[7]);
for (j = 0; j < 16; j += 1) {
W[j].h = x[i + 2 * j];
W[j].l = x[i + 2 * j + 1];
}
for (j = 16; j < 80; j += 1) {
//sigma1
int64rrot(r1, W[j - 2], 19);
int64revrrot(r2, W[j - 2], 29);
int64shr(r3, W[j - 2], 6);
s1.l = r1.l ^ r2.l ^ r3.l;
s1.h = r1.h ^ r2.h ^ r3.h;
//sigma0
int64rrot(r1, W[j - 15], 1);
int64rrot(r2, W[j - 15], 8);
int64shr(r3, W[j - 15], 7);
s0.l = r1.l ^ r2.l ^ r3.l;
s0.h = r1.h ^ r2.h ^ r3.h;
int64add4(W[j], s1, W[j - 7], s0, W[j - 16]);
}
for (j = 0; j < 80; j += 1) {
//Ch
Ch.l = (e.l & f.l) ^ (~e.l & g.l);
Ch.h = (e.h & f.h) ^ (~e.h & g.h);
//Sigma1
int64rrot(r1, e, 14);
int64rrot(r2, e, 18);
int64revrrot(r3, e, 9);
s1.l = r1.l ^ r2.l ^ r3.l;
s1.h = r1.h ^ r2.h ^ r3.h;
//Sigma0
int64rrot(r1, a, 28);
int64revrrot(r2, a, 2);
int64revrrot(r3, a, 7);
s0.l = r1.l ^ r2.l ^ r3.l;
s0.h = r1.h ^ r2.h ^ r3.h;
//Maj
Maj.l = (a.l & b.l) ^ (a.l & c.l) ^ (b.l & c.l);
Maj.h = (a.h & b.h) ^ (a.h & c.h) ^ (b.h & c.h);
int64add5(T1, h, s1, Ch, sha512_k[j], W[j]);
int64add(T2, s0, Maj);
int64copy(h, g);
int64copy(g, f);
int64copy(f, e);
int64add(e, d, T1);
int64copy(d, c);
int64copy(c, b);
int64copy(b, a);
int64add(a, T1, T2);
}
int64add(H[0], H[0], a);
int64add(H[1], H[1], b);
int64add(H[2], H[2], c);
int64add(H[3], H[3], d);
int64add(H[4], H[4], e);
int64add(H[5], H[5], f);
int64add(H[6], H[6], g);
int64add(H[7], H[7], h);
}
int64add(H[0], H[0], a);
int64add(H[1], H[1], b);
int64add(H[2], H[2], c);
int64add(H[3], H[3], d);
int64add(H[4], H[4], e);
int64add(H[5], H[5], f);
int64add(H[6], H[6], g);
int64add(H[7], H[7], h);
//represent the hash as an array of 32-bit dwords
for (i = 0; i < 8; i += 1) {
hash[2 * i] = H[i].h;
hash[2 * i + 1] = H[i].l;
}
return hash;
}
//represent the hash as an array of 32-bit dwords
for (i=0; i<8; i+=1) {
hash[2*i] = H[i].h;
hash[2*i + 1] = H[i].l;
//A constructor for 64-bit numbers
function int64(h, l) {
this.h = h;
this.l = l;
//this.toString = int64toString;
}
return hash;
}
//A constructor for 64-bit numbers
function int64(h, l) {
this.h = h;
this.l = l;
//this.toString = int64toString;
}
//Copies src into dst, assuming both are 64-bit numbers
function int64copy(dst, src) {
dst.h = src.h;
dst.l = src.l;
}
//Right-rotates a 64-bit number by shift
//Won't handle cases of shift>=32
//The function revrrot() is for that
function int64rrot(dst, x, shift) {
dst.l = (x.l >>> shift) | (x.h << (32-shift));
dst.h = (x.h >>> shift) | (x.l << (32-shift));
}
//Reverses the dwords of the source and then rotates right by shift.
//This is equivalent to rotation by 32+shift
function int64revrrot(dst, x, shift) {
dst.l = (x.h >>> shift) | (x.l << (32-shift));
dst.h = (x.l >>> shift) | (x.h << (32-shift));
}
//Bitwise-shifts right a 64-bit number by shift
//Won't handle shift>=32, but it's never needed in SHA512
function int64shr(dst, x, shift) {
dst.l = (x.l >>> shift) | (x.h << (32-shift));
dst.h = (x.h >>> shift);
}
//Adds two 64-bit numbers
//Like the original implementation, does not rely on 32-bit operations
function int64add(dst, x, y) {
var w0 = (x.l & 0xffff) + (y.l & 0xffff);
var w1 = (x.l >>> 16) + (y.l >>> 16) + (w0 >>> 16);
var w2 = (x.h & 0xffff) + (y.h & 0xffff) + (w1 >>> 16);
var w3 = (x.h >>> 16) + (y.h >>> 16) + (w2 >>> 16);
dst.l = (w0 & 0xffff) | (w1 << 16);
dst.h = (w2 & 0xffff) | (w3 << 16);
}
//Same, except with 4 addends. Works faster than adding them one by one.
function int64add4(dst, a, b, c, d) {
var w0 = (a.l & 0xffff) + (b.l & 0xffff) + (c.l & 0xffff) + (d.l & 0xffff);
var w1 = (a.l >>> 16) + (b.l >>> 16) + (c.l >>> 16) + (d.l >>> 16) + (w0 >>> 16);
var w2 = (a.h & 0xffff) + (b.h & 0xffff) + (c.h & 0xffff) + (d.h & 0xffff) + (w1 >>> 16);
var w3 = (a.h >>> 16) + (b.h >>> 16) + (c.h >>> 16) + (d.h >>> 16) + (w2 >>> 16);
dst.l = (w0 & 0xffff) | (w1 << 16);
dst.h = (w2 & 0xffff) | (w3 << 16);
}
//Same, except with 5 addends
function int64add5(dst, a, b, c, d, e) {
var w0 = (a.l & 0xffff) + (b.l & 0xffff) + (c.l & 0xffff) + (d.l & 0xffff) + (e.l & 0xffff),
//Copies src into dst, assuming both are 64-bit numbers
function int64copy(dst, src) {
dst.h = src.h;
dst.l = src.l;
}
//Right-rotates a 64-bit number by shift
//Won't handle cases of shift>=32
//The function revrrot() is for that
function int64rrot(dst, x, shift) {
dst.l = (x.l >>> shift) | (x.h << (32 - shift));
dst.h = (x.h >>> shift) | (x.l << (32 - shift));
}
//Reverses the dwords of the source and then rotates right by shift.
//This is equivalent to rotation by 32+shift
function int64revrrot(dst, x, shift) {
dst.l = (x.h >>> shift) | (x.l << (32 - shift));
dst.h = (x.l >>> shift) | (x.h << (32 - shift));
}
//Bitwise-shifts right a 64-bit number by shift
//Won't handle shift>=32, but it's never needed in SHA512
function int64shr(dst, x, shift) {
dst.l = (x.l >>> shift) | (x.h << (32 - shift));
dst.h = (x.h >>> shift);
}
//Adds two 64-bit numbers
//Like the original implementation, does not rely on 32-bit operations
function int64add(dst, x, y) {
var w0 = (x.l & 0xffff) + (y.l & 0xffff);
var w1 = (x.l >>> 16) + (y.l >>> 16) + (w0 >>> 16);
var w2 = (x.h & 0xffff) + (y.h & 0xffff) + (w1 >>> 16);
var w3 = (x.h >>> 16) + (y.h >>> 16) + (w2 >>> 16);
dst.l = (w0 & 0xffff) | (w1 << 16);
dst.h = (w2 & 0xffff) | (w3 << 16);
}
//Same, except with 4 addends. Works faster than adding them one by one.
function int64add4(dst, a, b, c, d) {
var w0 = (a.l & 0xffff) + (b.l & 0xffff) + (c.l & 0xffff) + (d.l & 0xffff);
var w1 = (a.l >>> 16) + (b.l >>> 16) + (c.l >>> 16) + (d.l >>> 16) + (w0 >>> 16);
var w2 = (a.h & 0xffff) + (b.h & 0xffff) + (c.h & 0xffff) + (d.h & 0xffff) + (w1 >>> 16);
var w3 = (a.h >>> 16) + (b.h >>> 16) + (c.h >>> 16) + (d.h >>> 16) + (w2 >>> 16);
dst.l = (w0 & 0xffff) | (w1 << 16);
dst.h = (w2 & 0xffff) | (w3 << 16);
}
//Same, except with 5 addends
function int64add5(dst, a, b, c, d, e) {
var w0 = (a.l & 0xffff) + (b.l & 0xffff) + (c.l & 0xffff) + (d.l & 0xffff) + (e.l & 0xffff),
w1 = (a.l >>> 16) + (b.l >>> 16) + (c.l >>> 16) + (d.l >>> 16) + (e.l >>> 16) + (w0 >>> 16),
w2 = (a.h & 0xffff) + (b.h & 0xffff) + (c.h & 0xffff) + (d.h & 0xffff) + (e.h & 0xffff) + (w1 >>> 16),
w3 = (a.h >>> 16) + (b.h >>> 16) + (c.h >>> 16) + (d.h >>> 16) + (e.h >>> 16) + (w2 >>> 16);
dst.l = (w0 & 0xffff) | (w1 << 16);
dst.h = (w2 & 0xffff) | (w3 << 16);
}
},
/**
* @class Hashes.RMD160
* @constructor
* @param {Object} [config]
*
* A JavaScript implementation of the RIPEMD-160 Algorithm
* Version 2.2 Copyright Jeremy Lin, Paul Johnston 2000 - 2009.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* See http://pajhome.org.uk/crypt/md5 for details.
* Also http://www.ocf.berkeley.edu/~jjlin/jsotp/
*/
RMD160 : function (options) {
dst.l = (w0 & 0xffff) | (w1 << 16);
dst.h = (w2 & 0xffff) | (w3 << 16);
}
},
/**
* Private properties configuration variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
* @see this.setUpperCase() method
* @see this.setPad() method
* @class Hashes.RMD160
* @constructor
* @param {Object} [config]
*
* A JavaScript implementation of the RIPEMD-160 Algorithm
* Version 2.2 Copyright Jeremy Lin, Paul Johnston 2000 - 2009.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* See http://pajhome.org.uk/crypt/md5 for details.
* Also http://www.ocf.berkeley.edu/~jjlin/jsotp/
*/
var hexcase = (options && typeof options.uppercase === 'boolean') ? options.uppercase : false, /* hexadecimal output case format. false - lowercase; true - uppercase */
b64pad = (options && typeof options.pad === 'string') ? options.pda : '=', /* base-64 pad character. Default '=' for strict RFC compliance */
utf8 = (options && typeof options.utf8 === 'boolean') ? options.utf8 : true, /* enable/disable utf8 encoding */
RMD160: function(options) {
/**
* Private properties configuration variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
* @see this.setUpperCase() method
* @see this.setPad() method
*/
var hexcase = (options && typeof options.uppercase === 'boolean') ? options.uppercase : false,
/* hexadecimal output case format. false - lowercase; true - uppercase */
b64pad = (options && typeof options.pad === 'string') ? options.pda : '=',
/* base-64 pad character. Default '=' for strict RFC compliance */
utf8 = (options && typeof options.utf8 === 'boolean') ? options.utf8 : true,
/* enable/disable utf8 encoding */
rmd160_r1 = [
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
],
rmd160_r2 = [
5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
],
rmd160_s1 = [
11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
],
rmd160_s2 = [
8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
];
/* privileged (public) methods */
this.hex = function (s) {
return rstr2hex(rstr(s, utf8));
};
this.b64 = function (s) {
return rstr2b64(rstr(s, utf8), b64pad);
};
this.any = function (s, e) {
return rstr2any(rstr(s, utf8), e);
};
this.hex_hmac = function (k, d) {
return rstr2hex(rstr_hmac(k, d));
};
this.b64_hmac = function (k, d) {
return rstr2b64(rstr_hmac(k, d), b64pad);
};
this.any_hmac = function (k, d, e) {
return rstr2any(rstr_hmac(k, d), e);
};
/**
* Perform a simple self-test to see if the VM is working
* @return {String} Hexadecimal hash sample
* @public
*/
this.vm_test = function () {
return hex('abc').toLowerCase() === '900150983cd24fb0d6963f7d28e17f72';
};
/**
* @description Enable/disable uppercase hexadecimal returned string
* @param {boolean}
* @return {Object} this
* @public
*/
this.setUpperCase = function (a) {
if (typeof a === 'boolean' ) { hexcase = a; }
return this;
};
/**
* @description Defines a base64 pad string
* @param {string} Pad
* @return {Object} this
* @public
*/
this.setPad = function (a) {
if (typeof a !== 'undefined' ) { b64pad = a; }
return this;
};
/**
* @description Defines a base64 pad string
* @param {boolean}
* @return {Object} this
* @public
*/
this.setUTF8 = function (a) {
if (typeof a === 'boolean') { utf8 = a; }
return this;
};
/* privileged (public) methods */
this.hex = function(s) {
return rstr2hex(rstr(s, utf8));
};
this.b64 = function(s) {
return rstr2b64(rstr(s, utf8), b64pad);
};
this.any = function(s, e) {
return rstr2any(rstr(s, utf8), e);
};
this.raw = function(s) {
return rstr(s, utf8);
};
this.hex_hmac = function(k, d) {
return rstr2hex(rstr_hmac(k, d));
};
this.b64_hmac = function(k, d) {
return rstr2b64(rstr_hmac(k, d), b64pad);
};
this.any_hmac = function(k, d, e) {
return rstr2any(rstr_hmac(k, d), e);
};
/**
* Perform a simple self-test to see if the VM is working
* @return {String} Hexadecimal hash sample
* @public
*/
this.vm_test = function() {
return hex('abc').toLowerCase() === '900150983cd24fb0d6963f7d28e17f72';
};
/**
* @description Enable/disable uppercase hexadecimal returned string
* @param {boolean}
* @return {Object} this
* @public
*/
this.setUpperCase = function(a) {
if (typeof a === 'boolean') {
hexcase = a;
}
return this;
};
/**
* @description Defines a base64 pad string
* @param {string} Pad
* @return {Object} this
* @public
*/
this.setPad = function(a) {
if (typeof a !== 'undefined') {
b64pad = a;
}
return this;
};
/**
* @description Defines a base64 pad string
* @param {boolean}
* @return {Object} this
* @public
*/
this.setUTF8 = function(a) {
if (typeof a === 'boolean') {
utf8 = a;
}
return this;
};
/* private methods */
/* private methods */
/**
* Calculate the rmd160 of a raw string
*/
function rstr(s) {
s = (utf8) ? utf8Encode(s) : s;
return binl2rstr(binl(rstr2binl(s), s.length * 8));
}
/**
* Calculate the rmd160 of a raw string
*/
/**
* Calculate the HMAC-rmd160 of a key and some data (raw strings)
*/
function rstr_hmac(key, data) {
key = (utf8) ? utf8Encode(key) : key;
data = (utf8) ? utf8Encode(data) : data;
var i, hash,
function rstr(s) {
s = (utf8) ? utf8Encode(s) : s;
return binl2rstr(binl(rstr2binl(s), s.length * 8));
}
/**
* Calculate the HMAC-rmd160 of a key and some data (raw strings)
*/
function rstr_hmac(key, data) {
key = (utf8) ? utf8Encode(key) : key;
data = (utf8) ? utf8Encode(data) : data;
var i, hash,
bkey = rstr2binl(key),
ipad = Array(16), opad = Array(16);
ipad = Array(16),
opad = Array(16);
if (bkey.length > 16) {
bkey = binl(bkey, key.length * 8);
if (bkey.length > 16) {
bkey = binl(bkey, key.length * 8);
}
for (i = 0; i < 16; i += 1) {
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
hash = binl(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
return binl2rstr(binl(opad.concat(hash), 512 + 160));
}
for (i = 0; i < 16; i+=1) {
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
hash = binl(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
return binl2rstr(binl(opad.concat(hash), 512 + 160));
}
/**
* Convert an array of little-endian words to a string
*/
function binl2rstr(input) {
var i, output = '', l = input.length * 32;
for (i = 0; i < l; i += 8) {
output += String.fromCharCode((input[i>>5] >>> (i % 32)) & 0xFF);
/**
* Convert an array of little-endian words to a string
*/
function binl2rstr(input) {
var i, output = '',
l = input.length * 32;
for (i = 0; i < l; i += 8) {
output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xFF);
}
return output;
}
return output;
}
/**
* Calculate the RIPE-MD160 of an array of little-endian words, and a bit length.
*/
function binl(x, len) {
var T, j, i, l,
/**
* Calculate the RIPE-MD160 of an array of little-endian words, and a bit length.
*/
function binl(x, len) {
var T, j, i, l,
h0 = 0x67452301,

@@ -1563,68 +1685,83 @@ h1 = 0xefcdab89,

/* append padding */
x[len >> 5] |= 0x80 << (len % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
l = x.length;
for (i = 0; i < l; i+=16) {
A1 = A2 = h0; B1 = B2 = h1; C1 = C2 = h2; D1 = D2 = h3; E1 = E2 = h4;
for (j = 0; j <= 79; j+=1) {
T = safe_add(A1, rmd160_f(j, B1, C1, D1));
T = safe_add(T, x[i + rmd160_r1[j]]);
T = safe_add(T, rmd160_K1(j));
T = safe_add(bit_rol(T, rmd160_s1[j]), E1);
A1 = E1; E1 = D1; D1 = bit_rol(C1, 10); C1 = B1; B1 = T;
T = safe_add(A2, rmd160_f(79-j, B2, C2, D2));
T = safe_add(T, x[i + rmd160_r2[j]]);
T = safe_add(T, rmd160_K2(j));
T = safe_add(bit_rol(T, rmd160_s2[j]), E2);
A2 = E2; E2 = D2; D2 = bit_rol(C2, 10); C2 = B2; B2 = T;
/* append padding */
x[len >> 5] |= 0x80 << (len % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
l = x.length;
for (i = 0; i < l; i += 16) {
A1 = A2 = h0;
B1 = B2 = h1;
C1 = C2 = h2;
D1 = D2 = h3;
E1 = E2 = h4;
for (j = 0; j <= 79; j += 1) {
T = safe_add(A1, rmd160_f(j, B1, C1, D1));
T = safe_add(T, x[i + rmd160_r1[j]]);
T = safe_add(T, rmd160_K1(j));
T = safe_add(bit_rol(T, rmd160_s1[j]), E1);
A1 = E1;
E1 = D1;
D1 = bit_rol(C1, 10);
C1 = B1;
B1 = T;
T = safe_add(A2, rmd160_f(79 - j, B2, C2, D2));
T = safe_add(T, x[i + rmd160_r2[j]]);
T = safe_add(T, rmd160_K2(j));
T = safe_add(bit_rol(T, rmd160_s2[j]), E2);
A2 = E2;
E2 = D2;
D2 = bit_rol(C2, 10);
C2 = B2;
B2 = T;
}
T = safe_add(h1, safe_add(C1, D2));
h1 = safe_add(h2, safe_add(D1, E2));
h2 = safe_add(h3, safe_add(E1, A2));
h3 = safe_add(h4, safe_add(A1, B2));
h4 = safe_add(h0, safe_add(B1, C2));
h0 = T;
}
return [h0, h1, h2, h3, h4];
}
T = safe_add(h1, safe_add(C1, D2));
h1 = safe_add(h2, safe_add(D1, E2));
h2 = safe_add(h3, safe_add(E1, A2));
h3 = safe_add(h4, safe_add(A1, B2));
h4 = safe_add(h0, safe_add(B1, C2));
h0 = T;
// specific algorithm methods
function rmd160_f(j, x, y, z) {
return (0 <= j && j <= 15) ? (x ^ y ^ z) :
(16 <= j && j <= 31) ? (x & y) | (~x & z) :
(32 <= j && j <= 47) ? (x | ~y) ^ z :
(48 <= j && j <= 63) ? (x & z) | (y & ~z) :
(64 <= j && j <= 79) ? x ^ (y | ~z) :
'rmd160_f: j out of range';
}
return [h0, h1, h2, h3, h4];
}
// specific algorithm methods
function rmd160_f(j, x, y, z) {
return ( 0 <= j && j <= 15) ? (x ^ y ^ z) :
(16 <= j && j <= 31) ? (x & y) | (~x & z) :
(32 <= j && j <= 47) ? (x | ~y) ^ z :
(48 <= j && j <= 63) ? (x & z) | (y & ~z) :
(64 <= j && j <= 79) ? x ^ (y | ~z) :
'rmd160_f: j out of range';
}
function rmd160_K1(j) {
return (0 <= j && j <= 15) ? 0x00000000 :
(16 <= j && j <= 31) ? 0x5a827999 :
(32 <= j && j <= 47) ? 0x6ed9eba1 :
(48 <= j && j <= 63) ? 0x8f1bbcdc :
(64 <= j && j <= 79) ? 0xa953fd4e :
'rmd160_K1: j out of range';
}
function rmd160_K1(j) {
return ( 0 <= j && j <= 15) ? 0x00000000 :
(16 <= j && j <= 31) ? 0x5a827999 :
(32 <= j && j <= 47) ? 0x6ed9eba1 :
(48 <= j && j <= 63) ? 0x8f1bbcdc :
(64 <= j && j <= 79) ? 0xa953fd4e :
'rmd160_K1: j out of range';
function rmd160_K2(j) {
return (0 <= j && j <= 15) ? 0x50a28be6 :
(16 <= j && j <= 31) ? 0x5c4dd124 :
(32 <= j && j <= 47) ? 0x6d703ef3 :
(48 <= j && j <= 63) ? 0x7a6d76e9 :
(64 <= j && j <= 79) ? 0x00000000 :
'rmd160_K2: j out of range';
}
}
};
function rmd160_K2(j){
return ( 0 <= j && j <= 15) ? 0x50a28be6 :
(16 <= j && j <= 31) ? 0x5c4dd124 :
(32 <= j && j <= 47) ? 0x6d703ef3 :
(48 <= j && j <= 63) ? 0x7a6d76e9 :
(64 <= j && j <= 79) ? 0x00000000 :
'rmd160_K2: j out of range';
}
}
};
// exposes Hashes
(function( window, undefined ) {
(function(window, undefined) {
var freeExports = false;
if (typeof exports === 'object' ) {
if (typeof exports === 'object') {
freeExports = exports;
if (exports && typeof global === 'object' && global && global === global.global ) { window = global; }
if (exports && typeof global === 'object' && global && global === global.global) {
window = global;
}
}

@@ -1634,7 +1771,8 @@

// define as an anonymous module, so, through path mapping, it can be aliased
define(function () { return Hashes; });
}
else if ( freeExports ) {
define(function() {
return Hashes;
});
} else if (freeExports) {
// in Node.js or RingoJS v0.8.0+
if ( typeof module === 'object' && module && module.exports === freeExports ) {
if (typeof module === 'object' && module && module.exports === freeExports) {
module.exports = Hashes;

@@ -1646,8 +1784,7 @@ }

}
}
else {
} else {
// in a browser or Rhino
window.Hashes = Hashes;
}
}( this ));
}(this));
}()); // IIFE

@@ -1,7 +0,2 @@

/*
jsHashes (minimized and closure compiled version)
@version 1.0.4
@license New BSD License
@see <https://github.com/h2non/jsHashes>
*/
(function(){function u(b){var c,m,d="",a=-1,l;if(b&&b.length)for(l=b.length;(a+=1)<l;)c=b.charCodeAt(a),m=a+1<l?b.charCodeAt(a+1):0,55296<=c&&(56319>=c&&56320<=m&&57343>=m)&&(c=65536+((c&1023)<<10)+(m&1023),a+=1),127>=c?d+=String.fromCharCode(c):2047>=c?d+=String.fromCharCode(192|c>>>6&31,128|c&63):65535>=c?d+=String.fromCharCode(224|c>>>12&15,128|c>>>6&63,128|c&63):2097151>=c&&(d+=String.fromCharCode(240|c>>>18&7,128|c>>>12&63,128|c>>>6&63,128|c&63));return d}function p(b,c){var m=(b&65535)+(c&65535);return(b>>16)+(c>>16)+(m>>16)<<16|m&65535}function F(b,c){return b<<c|b>>>32-c}function y(b,c){for(var m=c?"0123456789ABCDEF":"0123456789abcdef",d="",a,l=0,n=b.length;l<n;l+=1)a=b.charCodeAt(l),d+=m.charAt(a>>>4&15)+m.charAt(a&15);return d}function O(b){var c,m=32*b.length,d="";for(c=0;c<m;c+=8)d+=String.fromCharCode(b[c>>5]>>>24-c%32&255);return d}function V(b){var c,m=32*b.length,d="";for(c=0;c<m;c+=8)d+=String.fromCharCode(b[c>>5]>>>c%32&255);return d}function P(b){var c,m=8*b.length,d=Array(b.length>>2),a=d.length;for(c=0;c<a;c+=1)d[c]=0;for(c=0;c<m;c+=8)d[c>>5]|=(b.charCodeAt(c/8)&255)<<c%32;return d}function z(b){var c,m=8*b.length,d=Array(b.length>>2),a=d.length;for(c=0;c<a;c+=1)d[c]=0;for(c=0;c<m;c+=8)d[c>>5]|=(b.charCodeAt(c/8)&255)<<24-c%32;return d}function B(b,c){var m=c.length,d=[],a,l,n,s,q;q=Array(Math.ceil(b.length/2));l=q.length;for(a=0;a<l;a+=1)q[a]=b.charCodeAt(2*a)<<8|b.charCodeAt(2*a+1);for(;0<q.length;){s=[];for(a=n=0;a<q.length;a+=1)if(n=(n<<16)+q[a],l=Math.floor(n/m),n-=l*m,0<s.length||0<l)s[s.length]=l;d[d.length]=n;q=s}m="";for(a=d.length-1;0<=a;a--)m+=c.charAt(d[a]);d=Math.ceil(8*b.length/(Math.log(c.length)/Math.log(2)));for(a=m.length;a<d;a+=1)m=c[0]+m;return m}function w(b,c){var m="",d=b.length,a,l,n;c=c||"=";for(a=0;a<d;a+=3){n=b.charCodeAt(a)<<16|(a+1<d?b.charCodeAt(a+1)<<8:0)|(a+2<d?b.charCodeAt(a+2):0);for(l=0;4>l;l+=1)m=8*a+6*l>8*b.length?m+c:m+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n>>>6*(3-l)&63)}return m}var S;S={VERSION:"1.0.3",Base64:function(){var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c="=",m=!0;this.encode=function(d){var a,l,n,s="",q=d.length;c=c||"=";d=m?u(d):d;for(a=0;a<q;a+=3){n=d.charCodeAt(a)<<16|(a+1<q?d.charCodeAt(a+1)<<8:0)|(a+2<q?d.charCodeAt(a+2):0);for(l=0;4>l;l+=1)s=8*a+6*l>8*q?s+c:s+b.charAt(n>>>6*(3-l)&63)}return s};this.decode=function(d){var a,l,n,s,q,t,v;a="";var f=[];if(!d)return d;a=v=0;d=d.replace(RegExp("\\"+c,"gi"),"");do l=b.indexOf(d.charAt(a+=1)),n=b.indexOf(d.charAt(a+=1)),q=b.indexOf(d.charAt(a+=1)),t=b.indexOf(d.charAt(a+=1)),s=l<<18|n<<12|q<<6|t,l=s>>16&255,n=s>>8&255,s&=255,v+=1,f[v]=64===q?String.fromCharCode(l):64===t?String.fromCharCode(l,n):String.fromCharCode(l,n,s);while(a<d.length);a=f.join("");if(m){d=a;l=[];a=q=0;if(d&&d.length){n=d.length;for(d+="";a<n;)t=d.charCodeAt(a),q+=1,128>t?(l[q]=String.fromCharCode(t),a+=1):191<t&&224>t?(v=d.charCodeAt(a+1),l[q]=String.fromCharCode((t&31)<<6|v&63),a+=2):(v=d.charCodeAt(a+1),f=d.charCodeAt(a+2),l[q]=String.fromCharCode((t&15)<<12|(v&63)<<6|f&63),a+=3)}d=l.join("")}else d=a;return d};this.setPad=function(d){c=d||c;return this};this.setTab=function(d){b=d||b;return this};this.setUTF8=function(d){"boolean"===typeof d&&(m=d);return this}},CRC32:function(b){var c=0,m=0,m=0,d,a;b=u(b);c^=-1;d=0;for(a=b.length;d<a;d+=1)m=(c^b.charCodeAt(d))&255,m="0x"+"00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D".substr(9*m,8),c=c>>>8^m;return(c^-1)>>>0},MD5:function(b){function c(a){a=v?u(a):a;return V(d(P(a),8*a.length))}function m(a,r){var j,A,c,q;a=v?u(a):a;r=v?u(r):r;j=P(a);16<j.length&&(j=d(j,8*a.length));A=Array(16);c=Array(16);for(q=0;16>q;q+=1)A[q]=j[q]^909522486,c[q]=j[q]^1549556828;j=d(A.concat(P(r)),512+8*r.length);return V(d(c.concat(j),640))}function d(f,r){var j,A,d,c,q,k=1732584193,e=-271733879,h=-1732584194,g=271733878;f[r>>5]|=128<<r%32;f[(r+64>>>9<<4)+14]=r;for(j=0;j<f.length;j+=16)A=k,d=e,c=h,q=g,k=l(k,e,h,g,f[j+0],7,-680876936),g=l(g,k,e,h,f[j+1],12,-389564586),h=l(h,g,k,e,f[j+2],17,606105819),e=l(e,h,g,k,f[j+3],22,-1044525330),k=l(k,e,h,g,f[j+4],7,-176418897),g=l(g,k,e,h,f[j+5],12,1200080426),h=l(h,g,k,e,f[j+6],17,-1473231341),e=l(e,h,g,k,f[j+7],22,-45705983),k=l(k,e,h,g,f[j+8],7,1770035416),g=l(g,k,e,h,f[j+9],12,-1958414417),h=l(h,g,k,e,f[j+10],17,-42063),e=l(e,h,g,k,f[j+11],22,-1990404162),k=l(k,e,h,g,f[j+12],7,1804603682),g=l(g,k,e,h,f[j+13],12,-40341101),h=l(h,g,k,e,f[j+14],17,-1502002290),e=l(e,h,g,k,f[j+15],22,1236535329),k=n(k,e,h,g,f[j+1],5,-165796510),g=n(g,k,e,h,f[j+6],9,-1069501632),h=n(h,g,k,e,f[j+11],14,643717713),e=n(e,h,g,k,f[j+0],20,-373897302),k=n(k,e,h,g,f[j+5],5,-701558691),g=n(g,k,e,h,f[j+10],9,38016083),h=n(h,g,k,e,f[j+15],14,-660478335),e=n(e,h,g,k,f[j+4],20,-405537848),k=n(k,e,h,g,f[j+9],5,568446438),g=n(g,k,e,h,f[j+14],9,-1019803690),h=n(h,g,k,e,f[j+3],14,-187363961),e=n(e,h,g,k,f[j+8],20,1163531501),k=n(k,e,h,g,f[j+13],5,-1444681467),g=n(g,k,e,h,f[j+2],9,-51403784),h=n(h,g,k,e,f[j+7],14,1735328473),e=n(e,h,g,k,f[j+12],20,-1926607734),k=a(e^h^g,k,e,f[j+5],4,-378558),g=a(k^e^h,g,k,f[j+8],11,-2022574463),h=a(g^k^e,h,g,f[j+11],16,1839030562),e=a(h^g^k,e,h,f[j+14],23,-35309556),k=a(e^h^g,k,e,f[j+1],4,-1530992060),g=a(k^e^h,g,k,f[j+4],11,1272893353),h=a(g^k^e,h,g,f[j+7],16,-155497632),e=a(h^g^k,e,h,f[j+10],23,-1094730640),k=a(e^h^g,k,e,f[j+13],4,681279174),g=a(k^e^h,g,k,f[j+0],11,-358537222),h=a(g^k^e,h,g,f[j+3],16,-722521979),e=a(h^g^k,e,h,f[j+6],23,76029189),k=a(e^h^g,k,e,f[j+9],4,-640364487),g=a(k^e^h,g,k,f[j+12],11,-421815835),h=a(g^k^e,h,g,f[j+15],16,530742520),e=a(h^g^k,e,h,f[j+2],23,-995338651),k=s(k,e,h,g,f[j+0],6,-198630844),g=s(g,k,e,h,f[j+7],10,1126891415),h=s(h,g,k,e,f[j+14],15,-1416354905),e=s(e,h,g,k,f[j+5],21,-57434055),k=s(k,e,h,g,f[j+12],6,1700485571),g=s(g,k,e,h,f[j+3],10,-1894986606),h=s(h,g,k,e,f[j+10],15,-1051523),e=s(e,h,g,k,f[j+1],21,-2054922799),k=s(k,e,h,g,f[j+8],6,1873313359),g=s(g,k,e,h,f[j+15],10,-30611744),h=s(h,g,k,e,f[j+6],15,-1560198380),e=s(e,h,g,k,f[j+13],21,1309151649),k=s(k,e,h,g,f[j+4],6,-145523070),g=s(g,k,e,h,f[j+11],10,-1120210379),h=s(h,g,k,e,f[j+2],15,718787259),e=s(e,h,g,k,f[j+9],21,-343485551),k=p(k,A),e=p(e,d),h=p(h,c),g=p(g,q);return[k,e,h,g]}function a(a,r,j,A,d,c){return p(F(p(p(r,a),p(A,c)),d),j)}function l(f,r,j,A,d,c,q){return a(r&j|~r&A,f,r,d,c,q)}function n(f,r,j,d,c,q,b){return a(r&d|j&~d,f,r,c,q,b)}function s(f,r,j,d,c,q,b){return a(j^(r|~d),f,r,c,q,b)}var q=b&&"boolean"===typeof b.uppercase?b.uppercase:!1,t=b&&"string"===typeof b.pad?b.pda:"=",v=b&&"boolean"===typeof b.utf8?b.utf8:!0;this.hex=function(a){return y(c(a,v),q)};this.b64=function(a){return w(c(a),t)};this.any=function(a,r){return B(c(a,v),r)};this.hex_hmac=function(a,r){return y(m(a,r),q)};this.b64_hmac=function(a,r){return w(m(a,r),t)};this.any_hmac=function(a,r,j){return B(m(a,r),j)};this.vm_test=function(){return"900150983cd24fb0d6963f7d28e17f72"===hex("abc").toLowerCase()};this.setUpperCase=function(a){"boolean"===typeof a&&(q=a);return this};this.setPad=function(a){t=a||t;return this};this.setUTF8=function(a){"boolean"===typeof a&&(v=a);return this}},SHA1:function(b){function c(a){a=n?u(a):a;return O(d(z(a),8*a.length))}function m(a,c){var b,l,f,r;a=n?u(a):a;c=n?u(c):c;b=z(a);16<b.length&&(b=d(b,8*a.length));l=Array(16);f=Array(16);for(r=0;16>r;r+=1)l[r]=b[r]^909522486,f[r]=b[r]^1549556828;b=d(l.concat(z(c)),512+8*c.length);return O(d(f.concat(b),672))}function d(a,c){var d,b,f,r,j,A,l,n,m=Array(80),k=1732584193,e=-271733879,h=-1732584194,g=271733878,x=-1009589776;a[c>>5]|=128<<24-c%32;a[(c+64>>9<<4)+15]=c;for(d=0;d<a.length;d+=16){r=k;j=e;A=h;l=g;n=x;for(b=0;80>b;b+=1){m[b]=16>b?a[d+b]:F(m[b-3]^m[b-8]^m[b-14]^m[b-16],1);f=F(k,5);var T;T=20>b?e&h|~e&g:40>b?e^h^g:60>b?e&h|e&g|h&g:e^h^g;f=p(p(f,T),p(p(x,m[b]),20>b?1518500249:40>b?1859775393:60>b?-1894007588:-899497514));x=g;g=h;h=F(e,30);e=k;k=f}k=p(k,r);e=p(e,j);h=p(h,A);g=p(g,l);x=p(x,n)}return[k,e,h,g,x]}var a=b&&"boolean"===typeof b.uppercase?b.uppercase:!1,l=b&&"string"===typeof b.pad?b.pda:"=",n=b&&"boolean"===typeof b.utf8?b.utf8:!0;this.hex=function(d){return y(c(d,n),a)};this.b64=function(a){return w(c(a,n),l)};this.any=function(a,d){return B(c(a,n),d)};this.hex_hmac=function(a,c){return y(m(a,c))};this.b64_hmac=function(a,c){return w(m(a,c),l)};this.any_hmac=function(a,c,d){return B(m(a,c),d)};this.vm_test=function(){return"900150983cd24fb0d6963f7d28e17f72"===hex("abc").toLowerCase()};this.setUpperCase=function(c){"boolean"===typeof c&&(a=c);return this};this.setPad=function(a){l=a||l;return this};this.setUTF8=function(a){"boolean"===typeof a&&(n=a);return this}},SHA256:function(b){function c(c,d){c=d?u(c):c;return O(a(z(c),8*c.length))}function m(c,d){c=n?u(c):c;d=n?u(d):d;var b;b=0;var f=z(c),r=Array(16),j=Array(16);for(16<f.length&&(f=a(f,8*c.length));16>b;b+=1)r[b]=f[b]^909522486,j[b]=f[b]^1549556828;b=a(r.concat(z(d)),512+8*d.length);return O(a(j.concat(b),768))}function d(a,c){return a>>>c|a<<32-c}function a(a,c){var b=[1779033703,-1150833019,1013904242,-1521486534,1359893119,-1694144372,528734635,1541459225],f=Array(64),r,j,A,l,m,n,k,e,h,g,x,T;a[c>>5]|=128<<24-c%32;a[(c+64>>9<<4)+15]=c;for(h=0;h<a.length;h+=16){r=b[0];j=b[1];A=b[2];l=b[3];m=b[4];n=b[5];k=b[6];e=b[7];for(g=0;64>g;g+=1)f[g]=16>g?a[g+h]:p(p(p(d(f[g-2],17)^d(f[g-2],19)^f[g-2]>>>10,f[g-7]),d(f[g-15],7)^d(f[g-15],18)^f[g-15]>>>3),f[g-16]),x=p(p(p(p(e,d(m,6)^d(m,11)^d(m,25)),m&n^~m&k),s[g]),f[g]),T=p(d(r,2)^d(r,13)^d(r,22),r&j^r&A^j&A),e=k,k=n,n=m,m=p(l,x),l=A,A=j,j=r,r=p(x,T);b[0]=p(r,b[0]);b[1]=p(j,b[1]);b[2]=p(A,b[2]);b[3]=p(l,b[3]);b[4]=p(m,b[4]);b[5]=p(n,b[5]);b[6]=p(k,b[6]);b[7]=p(e,b[7])}return b}var l=b&&"string"===typeof b.pad?b.pda:"=",n=b&&"boolean"===typeof b.utf8?b.utf8:!0,s;this.hex=function(a){return y(c(a,n))};this.b64=function(a){return w(c(a,n),l)};this.any=function(a,b){return B(c(a,n),b)};this.hex_hmac=function(a,c){return y(m(a,c))};this.b64_hmac=function(a,c){return w(m(a,c),l)};this.any_hmac=function(a,c,b){return B(m(a,c),b)};this.vm_test=function(){return"900150983cd24fb0d6963f7d28e17f72"===hex("abc").toLowerCase()};this.setUpperCase=function(){return this};this.setPad=function(a){l=a||l;return this};this.setUTF8=function(a){"boolean"===typeof a&&(n=a);return this};s=[1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998]},SHA512:function(b){function c(a){a=v?u(a):a;return O(d(z(a),8*a.length))}function m(a,j){a=v?u(a):a;j=v?u(j):j;var c;c=0;var b=z(a),f=Array(32),l=Array(32);for(32<b.length&&(b=d(b,8*a.length));32>c;c+=1)f[c]=b[c]^909522486,l[c]=b[c]^1549556828;c=d(f.concat(z(j)),1024+8*j.length);return O(d(l.concat(c),1536))}function d(c,j){var b,d,m,t=Array(80),k=Array(16),e=[new a(1779033703,-205731576),new a(-1150833019,-2067093701),new a(1013904242,-23791573),new a(-1521486534,1595750129),new a(1359893119,-1377402159),new a(-1694144372,725511199),new a(528734635,-79577749),new a(1541459225,327033209)],h=new a(0,0),g=new a(0,0),x=new a(0,0),v=new a(0,0),u=new a(0,0),y=new a(0,0),D=new a(0,0),Q=new a(0,0),R=new a(0,0),G=new a(0,0),E=new a(0,0),C=new a(0,0),J=new a(0,0),B=new a(0,0),K=new a(0,0),L=new a(0,0),M=new a(0,0);void 0===f&&(f=[new a(1116352408,-685199838),new a(1899447441,602891725),new a(-1245643825,-330482897),new a(-373957723,-2121671748),new a(961987163,-213338824),new a(1508970993,-1241133031),new a(-1841331548,-1357295717),new a(-1424204075,-630357736),new a(-670586216,-1560083902),new a(310598401,1164996542),new a(607225278,1323610764),new a(1426881987,-704662302),new a(1925078388,-226784913),new a(-2132889090,991336113),new a(-1680079193,633803317),new a(-1046744716,-815192428),new a(-459576895,-1628353838),new a(-272742522,944711139),new a(264347078,-1953704523),new a(604807628,2007800933),new a(770255983,1495990901),new a(1249150122,1856431235),new a(1555081692,-1119749164),new a(1996064986,-2096016459),new a(-1740746414,-295247957),new a(-1473132947,766784016),new a(-1341970488,-1728372417),new a(-1084653625,-1091629340),new a(-958395405,1034457026),new a(-710438585,-1828018395),new a(113926993,-536640913),new a(338241895,168717936),new a(666307205,1188179964),new a(773529912,1546045734),new a(1294757372,1522805485),new a(1396182291,-1651133473),new a(1695183700,-1951439906),new a(1986661051,1014477480),new a(-2117940946,1206759142),new a(-1838011259,344077627),new a(-1564481375,1290863460),new a(-1474664885,-1136513023),new a(-1035236496,-789014639),new a(-949202525,106217008),new a(-778901479,-688958952),new a(-694614492,1432725776),new a(-200395387,1467031594),new a(275423344,851169720),new a(430227734,-1194143544),new a(506948616,1363258195),new a(659060556,-544281703),new a(883997877,-509917016),new a(958139571,-976659869),new a(1322822218,-482243893),new a(1537002063,2003034995),new a(1747873779,-692930397),new a(1955562222,1575990012),new a(2024104815,1125592928),new a(-2067236844,-1578062990),new a(-1933114872,442776044),new a(-1866530822,593698344),new a(-1538233109,-561857047),new a(-1090935817,-1295615723),new a(-965641998,-479046869),new a(-903397682,-366583396),new a(-779700025,566280711),new a(-354779690,-840897762),new a(-176337025,-294727304),new a(116418474,1914138554),new a(174292421,-1563912026),new a(289380356,-1090974290),new a(460393269,320620315),new a(685471733,587496836),new a(852142971,1086792851),new a(1017036298,365543100),new a(1126000580,-1676669620),new a(1288033470,-885112138),new a(1501505948,-60457430),new a(1607167915,987167468),new a(1816402316,1246189591)]);for(d=0;80>d;d+=1)t[d]=new a(0,0);c[j>>5]|=128<<24-(j&31);c[(j+128>>10<<5)+31]=j;m=c.length;for(d=0;d<m;d+=32){l(x,e[0]);l(v,e[1]);l(u,e[2]);l(y,e[3]);l(D,e[4]);l(Q,e[5]);l(R,e[6]);l(G,e[7]);for(b=0;16>b;b+=1)t[b].h=c[d+2*b],t[b].l=c[d+2*b+1];for(b=16;80>b;b+=1){n(K,t[b-2],19);p(L,t[b-2],29);var N=M,H=t[b-2];N.l=H.l>>>6|H.h<<26;N.h=H.h>>>6;C.l=K.l^L.l^M.l;C.h=K.h^L.h^M.h;n(K,t[b-15],1);n(L,t[b-15],8);N=M;H=t[b-15];N.l=H.l>>>7|H.h<<25;N.h=H.h>>>7;E.l=K.l^L.l^M.l;E.h=K.h^L.h^M.h;var N=t[b],I=t[b-7],w=t[b-16],H=(C.l&65535)+(I.l&65535)+(E.l&65535)+(w.l&65535),z=(C.l>>>16)+(I.l>>>16)+(E.l>>>16)+(w.l>>>16)+(H>>>16),F=(C.h&65535)+(I.h&65535)+(E.h&65535)+(w.h&65535)+(z>>>16),I=(C.h>>>16)+(I.h>>>16)+(E.h>>>16)+(w.h>>>16)+(F>>>16);N.l=H&65535|z<<16;N.h=F&65535|I<<16}for(b=0;80>b;b+=1)J.l=D.l&Q.l^~D.l&R.l,J.h=D.h&Q.h^~D.h&R.h,n(K,D,14),n(L,D,18),p(M,D,9),C.l=K.l^L.l^M.l,C.h=K.h^L.h^M.h,n(K,x,28),p(L,x,2),p(M,x,7),E.l=K.l^L.l^M.l,E.h=K.h^L.h^M.h,B.l=x.l&v.l^x.l&u.l^v.l&u.l,B.h=x.h&v.h^x.h&u.h^v.h&u.h,N=h,I=f[b],w=t[b],H=(G.l&65535)+(C.l&65535)+(J.l&65535)+(I.l&65535)+(w.l&65535),z=(G.l>>>16)+(C.l>>>16)+(J.l>>>16)+(I.l>>>16)+(w.l>>>16)+(H>>>16),F=(G.h&65535)+(C.h&65535)+(J.h&65535)+(I.h&65535)+(w.h&65535)+(z>>>16),I=(G.h>>>16)+(C.h>>>16)+(J.h>>>16)+(I.h>>>16)+(w.h>>>16)+(F>>>16),N.l=H&65535|z<<16,N.h=F&65535|I<<16,q(g,E,B),l(G,R),l(R,Q),l(Q,D),q(D,y,h),l(y,u),l(u,v),l(v,x),q(x,h,g);q(e[0],e[0],x);q(e[1],e[1],v);q(e[2],e[2],u);q(e[3],e[3],y);q(e[4],e[4],D);q(e[5],e[5],Q);q(e[6],e[6],R);q(e[7],e[7],G)}for(d=0;8>d;d+=1)k[2*d]=e[d].h,k[2*d+1]=e[d].l;return k}function a(a,b){this.h=a;this.l=b}function l(a,b){a.h=b.h;a.l=b.l}function n(a,b,c){a.l=b.l>>>c|b.h<<32-c;a.h=b.h>>>c|b.l<<32-c}function p(a,b,c){a.l=b.h>>>c|b.l<<32-c;a.h=b.l>>>c|b.h<<32-c}function q(a,b,c){var d=(b.l&65535)+(c.l&65535),f=(b.l>>>16)+(c.l>>>16)+(d>>>16),l=(b.h&65535)+(c.h&65535)+(f>>>16);b=(b.h>>>16)+(c.h>>>16)+(l>>>16);a.l=d&65535|f<<16;a.h=l&65535|b<<16}var t=b&&"string"===typeof b.pad?b.pda:"=",v=b&&"boolean"===typeof b.utf8?b.utf8:!0,f;this.hex=function(a){return y(c(a))};this.b64=function(a){return w(c(a),t)};this.any=function(a,b){return B(c(a),b)};this.hex_hmac=function(a,b){return y(m(a,b))};this.b64_hmac=function(a,b){return w(m(a,b),t)};this.any_hmac=function(a,b,c){return B(m(a,b),c)};this.vm_test=function(){return"900150983cd24fb0d6963f7d28e17f72"===hex("abc").toLowerCase()};this.setUpperCase=function(){return this};this.setPad=function(a){t=a||t;return this};this.setUTF8=function(a){"boolean"===typeof a&&(v=a);return this}},RMD160:function(b){function c(b){b=s?u(b):b;return d(a(P(b),8*b.length))}function m(b,c){b=s?u(b):b;c=s?u(c):c;var f,l=P(b),m=Array(16),n=Array(16);16<l.length&&(l=a(l,8*b.length));for(f=0;16>f;f+=1)m[f]=l[f]^909522486,n[f]=l[f]^1549556828;f=a(m.concat(P(c)),512+8*c.length);return d(a(n.concat(f),672))}function d(a){var b,c="",d=32*a.length;for(b=0;b<d;b+=8)c+=String.fromCharCode(a[b>>5]>>>b%32&255);return c}function a(a,b){var c,d,m,n,k=1732584193,e=4023233417,h=2562383102,g=271733878,s=3285377520,u,w,y,D,z,B,G,E,C,J;a[b>>5]|=128<<b%32;a[(b+64>>>9<<4)+14]=b;n=a.length;for(m=0;m<n;m+=16){u=B=k;w=G=e;y=E=h;D=C=g;z=J=s;for(d=0;79>=d;d+=1)c=p(u,l(d,w,y,D)),c=p(c,a[m+q[d]]),c=p(c,0<=d&&15>=d?0:16<=d&&31>=d?1518500249:32<=d&&47>=d?1859775393:48<=d&&63>=d?2400959708:64<=d&&79>=d?2840853838:"rmd160_K1: j out of range"),c=p(F(c,v[d]),z),u=z,z=D,D=F(y,10),y=w,w=c,c=p(B,l(79-d,G,E,C)),c=p(c,a[m+t[d]]),c=p(c,0<=d&&15>=d?1352829926:16<=d&&31>=d?1548603684:32<=d&&47>=d?1836072691:48<=d&&63>=d?2053994217:64<=d&&79>=d?0:"rmd160_K2: j out of range"),c=p(F(c,f[d]),J),B=J,J=C,C=F(E,10),E=G,G=c;c=p(e,p(y,C));e=p(h,p(D,J));h=p(g,p(z,B));g=p(s,p(u,G));s=p(k,p(w,E));k=c}return[k,e,h,g,s]}function l(a,b,c,d){return 0<=a&&15>=a?b^c^d:16<=a&&31>=a?b&c|~b&d:32<=a&&47>=a?(b|~c)^d:48<=a&&63>=a?b&d|c&~d:64<=a&&79>=a?b^(c|~d):"rmd160_f: j out of range"}var n=b&&"string"===typeof b.pad?b.pda:"=",s=b&&"boolean"===typeof b.utf8?b.utf8:!0,q=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],t=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],v=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],f=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11];this.hex=function(a){return y(c(a,s))};this.b64=function(a){return w(c(a,s),n)};this.any=function(a,b){return B(c(a,s),b)};this.hex_hmac=function(a,b){return y(m(a,b))};this.b64_hmac=function(a,b){return w(m(a,b),n)};this.any_hmac=function(a,b,c){return B(m(a,b),c)};this.vm_test=function(){return"900150983cd24fb0d6963f7d28e17f72"===hex("abc").toLowerCase()};this.setUpperCase=function(){return this};this.setPad=function(a){"undefined"!==typeof a&&(n=a);return this};this.setUTF8=function(a){"boolean"===typeof a&&(s=a);return this}}};var W=this,U=!1;"object"===typeof exports&&(U=exports)&&("object"===typeof global&&global&&global===global.global)&&(W=global);"function"===typeof define&&"object"===typeof define.amd&&define.amd?define(function(){return S}):U?"object"===typeof module&&module&&module.exports===U?module.exports=S:U.Hashes=S:W.Hashes=S})();
/*! jshashes - New BSD License - https://github.com/h2non/jshashes */
(function(){var n;function e(n){var e,t,r="",o=-1,f;if(n&&n.length){f=n.length;while((o+=1)<f){e=n.charCodeAt(o);t=o+1<f?n.charCodeAt(o+1):0;if(55296<=e&&e<=56319&&56320<=t&&t<=57343){e=65536+((e&1023)<<10)+(t&1023);o+=1}if(e<=127){r+=String.fromCharCode(e)}else if(e<=2047){r+=String.fromCharCode(192|e>>>6&31,128|e&63)}else if(e<=65535){r+=String.fromCharCode(224|e>>>12&15,128|e>>>6&63,128|e&63)}else if(e<=2097151){r+=String.fromCharCode(240|e>>>18&7,128|e>>>12&63,128|e>>>6&63,128|e&63)}}}return r}function t(n){var e,t,r,o,f,i=[],h;e=t=r=o=f=0;if(n&&n.length){h=n.length;n+="";while(e<h){r=n.charCodeAt(e);t+=1;if(r<128){i[t]=String.fromCharCode(r);e+=1}else if(r>191&&r<224){o=n.charCodeAt(e+1);i[t]=String.fromCharCode((r&31)<<6|o&63);e+=2}else{o=n.charCodeAt(e+1);f=n.charCodeAt(e+2);i[t]=String.fromCharCode((r&15)<<12|(o&63)<<6|f&63);e+=3}}}return i.join("")}function r(n,e){var t=(n&65535)+(e&65535),r=(n>>16)+(e>>16)+(t>>16);return r<<16|t&65535}function o(n,e){return n<<e|n>>>32-e}function f(n,e){var t=e?"0123456789ABCDEF":"0123456789abcdef",r="",o,f=0,i=n.length;for(;f<i;f+=1){o=n.charCodeAt(f);r+=t.charAt(o>>>4&15)+t.charAt(o&15)}return r}function i(n){var e,t=n.length,r="";for(e=0;e<t;e+=1){r+=String.fromCharCode(n.charCodeAt(e)&255,n.charCodeAt(e)>>>8&255)}return r}function h(n){var e,t=n.length,r="";for(e=0;e<t;e+=1){r+=String.fromCharCode(n.charCodeAt(e)>>>8&255,n.charCodeAt(e)&255)}return r}function u(n){var e,t=n.length*32,r="";for(e=0;e<t;e+=8){r+=String.fromCharCode(n[e>>5]>>>24-e%32&255)}return r}function a(n){var e,t=n.length*32,r="";for(e=0;e<t;e+=8){r+=String.fromCharCode(n[e>>5]>>>e%32&255)}return r}function c(n){var e,t=n.length*8,r=Array(n.length>>2),o=r.length;for(e=0;e<o;e+=1){r[e]=0}for(e=0;e<t;e+=8){r[e>>5]|=(n.charCodeAt(e/8)&255)<<e%32}return r}function l(n){var e,t=n.length*8,r=Array(n.length>>2),o=r.length;for(e=0;e<o;e+=1){r[e]=0}for(e=0;e<t;e+=8){r[e>>5]|=(n.charCodeAt(e/8)&255)<<24-e%32}return r}function D(n,e){var t=e.length,r=Array(),o,f,i,h,u,a,c,l;a=Array(Math.ceil(n.length/2));h=a.length;for(o=0;o<h;o+=1){a[o]=n.charCodeAt(o*2)<<8|n.charCodeAt(o*2+1)}while(a.length>0){u=Array();i=0;for(o=0;o<a.length;o+=1){i=(i<<16)+a[o];f=Math.floor(i/t);i-=f*t;if(u.length>0||f>0){u[u.length]=f}}r[r.length]=i;a=u}c="";for(o=r.length-1;o>=0;o--){c+=e.charAt(r[o])}l=Math.ceil(n.length*8/(Math.log(e.length)/Math.log(2)));for(o=c.length;o<l;o+=1){c=e[0]+c}return c}function B(n,e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r="",o=n.length,f,i,h;e=e||"=";for(f=0;f<o;f+=3){h=n.charCodeAt(f)<<16|(f+1<o?n.charCodeAt(f+1)<<8:0)|(f+2<o?n.charCodeAt(f+2):0);for(i=0;i<4;i+=1){if(f*8+i*6>n.length*8){r+=e}else{r+=t.charAt(h>>>6*(3-i)&63)}}}return r}n={VERSION:"1.0.5",Base64:function(){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r="=",o=false,f=true;this.encode=function(t){var o,i,h,u="",a=t.length;r=r||"=";t=f?e(t):t;for(o=0;o<a;o+=3){h=t.charCodeAt(o)<<16|(o+1<a?t.charCodeAt(o+1)<<8:0)|(o+2<a?t.charCodeAt(o+2):0);for(i=0;i<4;i+=1){if(o*8+i*6>a*8){u+=r}else{u+=n.charAt(h>>>6*(3-i)&63)}}}return u};this.decode=function(e){var o,i,h,u,a,c,l,D,B,C,A="",s=[];if(!e){return e}o=C=0;e=e.replace(new RegExp("\\"+r,"gi"),"");do{a=n.indexOf(e.charAt(o+=1));c=n.indexOf(e.charAt(o+=1));l=n.indexOf(e.charAt(o+=1));D=n.indexOf(e.charAt(o+=1));B=a<<18|c<<12|l<<6|D;i=B>>16&255;h=B>>8&255;u=B&255;C+=1;if(l===64){s[C]=String.fromCharCode(i)}else if(D===64){s[C]=String.fromCharCode(i,h)}else{s[C]=String.fromCharCode(i,h,u)}}while(o<e.length);A=s.join("");A=f?t(A):A;return A};this.setPad=function(n){r=n||r;return this};this.setTab=function(e){n=e||n;return this};this.setUTF8=function(n){if(typeof n==="boolean"){f=n}return this}},CRC32:function(n){var t=0,r=0,o=0,f,i,h;n=e(n);f=["00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 ","79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 ","84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F ","63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD ","A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC ","51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 ","B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 ","06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 ","E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 ","12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 ","D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 ","33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 ","CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 ","9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E ","7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D ","806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 ","60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA ","AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 ","5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 ","B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 ","05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 ","F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA ","11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 ","D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F ","30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E ","C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D"].join("");t=t^-1;for(i=0,h=n.length;i<h;i+=1){o=(t^n.charCodeAt(i))&255;r="0x"+f.substr(o*9,8);t=t>>>8^r}return(t^-1)>>>0},MD5:function(n){var t=n&&typeof n.uppercase==="boolean"?n.uppercase:false,i=n&&typeof n.pad==="string"?n.pda:"=",h=n&&typeof n.utf8==="boolean"?n.utf8:true;this.hex=function(n){return f(u(n,h),t)};this.b64=function(n){return B(u(n),i)};this.any=function(n,e){return D(u(n,h),e)};this.raw=function(n){return u(n,h)};this.hex_hmac=function(n,e){return f(l(n,e),t)};this.b64_hmac=function(n,e){return B(l(n,e),i)};this.any_hmac=function(n,e,t){return D(l(n,e),t)};this.vm_test=function(){return hex("abc").toLowerCase()==="900150983cd24fb0d6963f7d28e17f72"};this.setUpperCase=function(n){if(typeof n==="boolean"){t=n}return this};this.setPad=function(n){i=n||i;return this};this.setUTF8=function(n){if(typeof n==="boolean"){h=n}return this};function u(n){n=h?e(n):n;return a(C(c(n),n.length*8))}function l(n,t){var r,o,f,i,u;n=h?e(n):n;t=h?e(t):t;r=c(n);if(r.length>16){r=C(r,n.length*8)}o=Array(16),f=Array(16);for(u=0;u<16;u+=1){o[u]=r[u]^909522486;f[u]=r[u]^1549556828}i=C(o.concat(c(t)),512+t.length*8);return a(C(f.concat(i),512+128))}function C(n,e){var t,o,f,i,h,u=1732584193,a=-271733879,c=-1732584194,l=271733878;n[e>>5]|=128<<e%32;n[(e+64>>>9<<4)+14]=e;for(t=0;t<n.length;t+=16){o=u;f=a;i=c;h=l;u=s(u,a,c,l,n[t+0],7,-680876936);l=s(l,u,a,c,n[t+1],12,-389564586);c=s(c,l,u,a,n[t+2],17,606105819);a=s(a,c,l,u,n[t+3],22,-1044525330);u=s(u,a,c,l,n[t+4],7,-176418897);l=s(l,u,a,c,n[t+5],12,1200080426);c=s(c,l,u,a,n[t+6],17,-1473231341);a=s(a,c,l,u,n[t+7],22,-45705983);u=s(u,a,c,l,n[t+8],7,1770035416);l=s(l,u,a,c,n[t+9],12,-1958414417);c=s(c,l,u,a,n[t+10],17,-42063);a=s(a,c,l,u,n[t+11],22,-1990404162);u=s(u,a,c,l,n[t+12],7,1804603682);l=s(l,u,a,c,n[t+13],12,-40341101);c=s(c,l,u,a,n[t+14],17,-1502002290);a=s(a,c,l,u,n[t+15],22,1236535329);u=w(u,a,c,l,n[t+1],5,-165796510);l=w(l,u,a,c,n[t+6],9,-1069501632);c=w(c,l,u,a,n[t+11],14,643717713);a=w(a,c,l,u,n[t+0],20,-373897302);u=w(u,a,c,l,n[t+5],5,-701558691);l=w(l,u,a,c,n[t+10],9,38016083);c=w(c,l,u,a,n[t+15],14,-660478335);a=w(a,c,l,u,n[t+4],20,-405537848);u=w(u,a,c,l,n[t+9],5,568446438);l=w(l,u,a,c,n[t+14],9,-1019803690);c=w(c,l,u,a,n[t+3],14,-187363961);a=w(a,c,l,u,n[t+8],20,1163531501);u=w(u,a,c,l,n[t+13],5,-1444681467);l=w(l,u,a,c,n[t+2],9,-51403784);c=w(c,l,u,a,n[t+7],14,1735328473);a=w(a,c,l,u,n[t+12],20,-1926607734);u=F(u,a,c,l,n[t+5],4,-378558);l=F(l,u,a,c,n[t+8],11,-2022574463);c=F(c,l,u,a,n[t+11],16,1839030562);a=F(a,c,l,u,n[t+14],23,-35309556);u=F(u,a,c,l,n[t+1],4,-1530992060);l=F(l,u,a,c,n[t+4],11,1272893353);c=F(c,l,u,a,n[t+7],16,-155497632);a=F(a,c,l,u,n[t+10],23,-1094730640);u=F(u,a,c,l,n[t+13],4,681279174);l=F(l,u,a,c,n[t+0],11,-358537222);c=F(c,l,u,a,n[t+3],16,-722521979);a=F(a,c,l,u,n[t+6],23,76029189);u=F(u,a,c,l,n[t+9],4,-640364487);l=F(l,u,a,c,n[t+12],11,-421815835);c=F(c,l,u,a,n[t+15],16,530742520);a=F(a,c,l,u,n[t+2],23,-995338651);u=E(u,a,c,l,n[t+0],6,-198630844);l=E(l,u,a,c,n[t+7],10,1126891415);c=E(c,l,u,a,n[t+14],15,-1416354905);a=E(a,c,l,u,n[t+5],21,-57434055);u=E(u,a,c,l,n[t+12],6,1700485571);l=E(l,u,a,c,n[t+3],10,-1894986606);c=E(c,l,u,a,n[t+10],15,-1051523);a=E(a,c,l,u,n[t+1],21,-2054922799);u=E(u,a,c,l,n[t+8],6,1873313359);l=E(l,u,a,c,n[t+15],10,-30611744);c=E(c,l,u,a,n[t+6],15,-1560198380);a=E(a,c,l,u,n[t+13],21,1309151649);u=E(u,a,c,l,n[t+4],6,-145523070);l=E(l,u,a,c,n[t+11],10,-1120210379);c=E(c,l,u,a,n[t+2],15,718787259);a=E(a,c,l,u,n[t+9],21,-343485551);u=r(u,o);a=r(a,f);c=r(c,i);l=r(l,h)}return Array(u,a,c,l)}function A(n,e,t,f,i,h){return r(o(r(r(e,n),r(f,h)),i),t)}function s(n,e,t,r,o,f,i){return A(e&t|~e&r,n,e,o,f,i)}function w(n,e,t,r,o,f,i){return A(e&r|t&~r,n,e,o,f,i)}function F(n,e,t,r,o,f,i){return A(e^t^r,n,e,o,f,i)}function E(n,e,t,r,o,f,i){return A(t^(e|~r),n,e,o,f,i)}},SHA1:function(n){var t=n&&typeof n.uppercase==="boolean"?n.uppercase:false,i=n&&typeof n.pad==="string"?n.pda:"=",h=n&&typeof n.utf8==="boolean"?n.utf8:true;this.hex=function(n){return f(a(n,h),t)};this.b64=function(n){return B(a(n,h),i)};this.any=function(n,e){return D(a(n,h),e)};this.raw=function(n){return a(n,h)};this.hex_hmac=function(n,e){return f(c(n,e))};this.b64_hmac=function(n,e){return B(c(n,e),i)};this.any_hmac=function(n,e,t){return D(c(n,e),t)};this.vm_test=function(){return hex("abc").toLowerCase()==="900150983cd24fb0d6963f7d28e17f72"};this.setUpperCase=function(n){if(typeof n==="boolean"){t=n}return this};this.setPad=function(n){i=n||i;return this};this.setUTF8=function(n){if(typeof n==="boolean"){h=n}return this};function a(n){n=h?e(n):n;return u(C(l(n),n.length*8))}function c(n,t){var r,o,f,i,a;n=h?e(n):n;t=h?e(t):t;r=l(n);if(r.length>16){r=C(r,n.length*8)}o=Array(16),f=Array(16);for(i=0;i<16;i+=1){o[i]=r[i]^909522486;f[i]=r[i]^1549556828}a=C(o.concat(l(t)),512+t.length*8);return u(C(f.concat(a),512+160))}function C(n,e){var t,f,i,h,u,a,c,l,D=Array(80),B=1732584193,C=-271733879,w=-1732584194,F=271733878,E=-1009589776;n[e>>5]|=128<<24-e%32;n[(e+64>>9<<4)+15]=e;for(t=0;t<n.length;t+=16){h=B,u=C;a=w;c=F;l=E;for(f=0;f<80;f+=1){if(f<16){D[f]=n[t+f]}else{D[f]=o(D[f-3]^D[f-8]^D[f-14]^D[f-16],1)}i=r(r(o(B,5),A(f,C,w,F)),r(r(E,D[f]),s(f)));E=F;F=w;w=o(C,30);C=B;B=i}B=r(B,h);C=r(C,u);w=r(w,a);F=r(F,c);E=r(E,l)}return Array(B,C,w,F,E)}function A(n,e,t,r){if(n<20){return e&t|~e&r}if(n<40){return e^t^r}if(n<60){return e&t|e&r|t&r}return e^t^r}function s(n){return n<20?1518500249:n<40?1859775393:n<60?-1894007588:-899497514}},SHA256:function(n){var t=n&&typeof n.uppercase==="boolean"?n.uppercase:false,o=n&&typeof n.pad==="string"?n.pda:"=",i=n&&typeof n.utf8==="boolean"?n.utf8:true,h;this.hex=function(n){return f(a(n,i))};this.b64=function(n){return B(a(n,i),o)};this.any=function(n,e){return D(a(n,i),e)};this.raw=function(n){return a(n,i)};this.hex_hmac=function(n,e){return f(c(n,e))};this.b64_hmac=function(n,e){return B(c(n,e),o)};this.any_hmac=function(n,e,t){return D(c(n,e),t)};this.vm_test=function(){return hex("abc").toLowerCase()==="900150983cd24fb0d6963f7d28e17f72"};this.setUpperCase=function(n){if(typeof n==="boolean"){t=n}return this};this.setPad=function(n){o=n||o;return this};this.setUTF8=function(n){if(typeof n==="boolean"){i=n}return this};function a(n,t){n=t?e(n):n;return u(m(l(n),n.length*8))}function c(n,t){n=i?e(n):n;t=i?e(t):t;var r,o=0,f=l(n),h=Array(16),a=Array(16);if(f.length>16){f=m(f,n.length*8)}for(;o<16;o+=1){h[o]=f[o]^909522486;a[o]=f[o]^1549556828}r=m(h.concat(l(t)),512+t.length*8);return u(m(a.concat(r),512+256))}function C(n,e){return n>>>e|n<<32-e}function A(n,e){return n>>>e}function s(n,e,t){return n&e^~n&t}function w(n,e,t){return n&e^n&t^e&t}function F(n){return C(n,2)^C(n,13)^C(n,22)}function E(n){return C(n,6)^C(n,11)^C(n,25)}function d(n){return C(n,7)^C(n,18)^A(n,3)}function g(n){return C(n,17)^C(n,19)^A(n,10)}function p(n){return C(n,28)^C(n,34)^C(n,39)}function y(n){return C(n,14)^C(n,18)^C(n,41)}function b(n){return C(n,1)^C(n,8)^A(n,7)}function v(n){return C(n,19)^C(n,61)^A(n,6)}h=[1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998];function m(n,e){var t=[1779033703,-1150833019,1013904242,-1521486534,1359893119,-1694144372,528734635,1541459225];var o=new Array(64);var f,i,u,a,c,l,D,B;var C,A,p,y;n[e>>5]|=128<<24-e%32;n[(e+64>>9<<4)+15]=e;for(C=0;C<n.length;C+=16){f=t[0];i=t[1];u=t[2];a=t[3];c=t[4];l=t[5];D=t[6];B=t[7];for(A=0;A<64;A+=1){if(A<16){o[A]=n[A+C]}else{o[A]=r(r(r(g(o[A-2]),o[A-7]),d(o[A-15])),o[A-16])}p=r(r(r(r(B,E(c)),s(c,l,D)),h[A]),o[A]);y=r(F(f),w(f,i,u));B=D;D=l;l=c;c=r(a,p);a=u;u=i;i=f;f=r(p,y)}t[0]=r(f,t[0]);t[1]=r(i,t[1]);t[2]=r(u,t[2]);t[3]=r(a,t[3]);t[4]=r(c,t[4]);t[5]=r(l,t[5]);t[6]=r(D,t[6]);t[7]=r(B,t[7])}return t}},SHA512:function(n){var t=n&&typeof n.uppercase==="boolean"?n.uppercase:false,r=n&&typeof n.pad==="string"?n.pda:"=",o=n&&typeof n.utf8==="boolean"?n.utf8:true,i;this.hex=function(n){return f(h(n))};this.b64=function(n){return B(h(n),r)};this.any=function(n,e){return D(h(n),e)};this.raw=function(n){return h(n,o)};this.hex_hmac=function(n,e){return f(a(n,e))};this.b64_hmac=function(n,e){return B(a(n,e),r)};this.any_hmac=function(n,e,t){return D(a(n,e),t)};this.vm_test=function(){return hex("abc").toLowerCase()==="900150983cd24fb0d6963f7d28e17f72"};this.setUpperCase=function(n){if(typeof n==="boolean"){t=n}return this};this.setPad=function(n){r=n||r;return this};this.setUTF8=function(n){if(typeof n==="boolean"){o=n}return this};function h(n){n=o?e(n):n;return u(c(l(n),n.length*8))}function a(n,t){n=o?e(n):n;t=o?e(t):t;var r,f=0,i=l(n),h=Array(32),a=Array(32);if(i.length>32){i=c(i,n.length*8)}for(;f<32;f+=1){h[f]=i[f]^909522486;a[f]=i[f]^1549556828}r=c(h.concat(l(t)),1024+t.length*8);return u(c(a.concat(r),1024+512))}function c(n,e){var t,r,o,f=new Array(80),h=new Array(16),u=[new C(1779033703,-205731576),new C(-1150833019,-2067093701),new C(1013904242,-23791573),new C(-1521486534,1595750129),new C(1359893119,-1377402159),new C(-1694144372,725511199),new C(528734635,-79577749),new C(1541459225,327033209)],a=new C(0,0),c=new C(0,0),l=new C(0,0),D=new C(0,0),B=new C(0,0),p=new C(0,0),y=new C(0,0),b=new C(0,0),v=new C(0,0),m=new C(0,0),x=new C(0,0),_=new C(0,0),S=new C(0,0),U=new C(0,0),j=new C(0,0),M=new C(0,0),T=new C(0,0);if(i===undefined){i=[new C(1116352408,-685199838),new C(1899447441,602891725),new C(-1245643825,-330482897),new C(-373957723,-2121671748),new C(961987163,-213338824),new C(1508970993,-1241133031),new C(-1841331548,-1357295717),new C(-1424204075,-630357736),new C(-670586216,-1560083902),new C(310598401,1164996542),new C(607225278,1323610764),new C(1426881987,-704662302),new C(1925078388,-226784913),new C(-2132889090,991336113),new C(-1680079193,633803317),new C(-1046744716,-815192428),new C(-459576895,-1628353838),new C(-272742522,944711139),new C(264347078,-1953704523),new C(604807628,2007800933),new C(770255983,1495990901),new C(1249150122,1856431235),new C(1555081692,-1119749164),new C(1996064986,-2096016459),new C(-1740746414,-295247957),new C(-1473132947,766784016),new C(-1341970488,-1728372417),new C(-1084653625,-1091629340),new C(-958395405,1034457026),new C(-710438585,-1828018395),new C(113926993,-536640913),new C(338241895,168717936),new C(666307205,1188179964),new C(773529912,1546045734),new C(1294757372,1522805485),new C(1396182291,-1651133473),new C(1695183700,-1951439906),new C(1986661051,1014477480),new C(-2117940946,1206759142),new C(-1838011259,344077627),new C(-1564481375,1290863460),new C(-1474664885,-1136513023),new C(-1035236496,-789014639),new C(-949202525,106217008),new C(-778901479,-688958952),new C(-694614492,1432725776),new C(-200395387,1467031594),new C(275423344,851169720),new C(430227734,-1194143544),new C(506948616,1363258195),new C(659060556,-544281703),new C(883997877,-509917016),new C(958139571,-976659869),new C(1322822218,-482243893),new C(1537002063,2003034995),new C(1747873779,-692930397),new C(1955562222,1575990012),new C(2024104815,1125592928),new C(-2067236844,-1578062990),new C(-1933114872,442776044),new C(-1866530822,593698344),new C(-1538233109,-561857047),new C(-1090935817,-1295615723),new C(-965641998,-479046869),new C(-903397682,-366583396),new C(-779700025,566280711),new C(-354779690,-840897762),new C(-176337025,-294727304),new C(116418474,1914138554),new C(174292421,-1563912026),new C(289380356,-1090974290),new C(460393269,320620315),new C(685471733,587496836),new C(852142971,1086792851),new C(1017036298,365543100),new C(1126000580,-1676669620),new C(1288033470,-885112138),new C(1501505948,-60457430),new C(1607167915,987167468),new C(1816402316,1246189591)]}for(r=0;r<80;r+=1){f[r]=new C(0,0)}n[e>>5]|=128<<24-(e&31);n[(e+128>>10<<5)+31]=e;o=n.length;for(r=0;r<o;r+=32){A(l,u[0]);A(D,u[1]);A(B,u[2]);A(p,u[3]);A(y,u[4]);A(b,u[5]);A(v,u[6]);A(m,u[7]);for(t=0;t<16;t+=1){f[t].h=n[r+2*t];f[t].l=n[r+2*t+1]}for(t=16;t<80;t+=1){s(j,f[t-2],19);w(M,f[t-2],29);F(T,f[t-2],6);_.l=j.l^M.l^T.l;_.h=j.h^M.h^T.h;s(j,f[t-15],1);s(M,f[t-15],8);F(T,f[t-15],7);x.l=j.l^M.l^T.l;x.h=j.h^M.h^T.h;d(f[t],_,f[t-7],x,f[t-16])}for(t=0;t<80;t+=1){S.l=y.l&b.l^~y.l&v.l;S.h=y.h&b.h^~y.h&v.h;s(j,y,14);s(M,y,18);w(T,y,9);_.l=j.l^M.l^T.l;_.h=j.h^M.h^T.h;s(j,l,28);w(M,l,2);w(T,l,7);x.l=j.l^M.l^T.l;x.h=j.h^M.h^T.h;U.l=l.l&D.l^l.l&B.l^D.l&B.l;U.h=l.h&D.h^l.h&B.h^D.h&B.h;g(a,m,_,S,i[t],f[t]);E(c,x,U);A(m,v);A(v,b);A(b,y);E(y,p,a);A(p,B);A(B,D);A(D,l);E(l,a,c)}E(u[0],u[0],l);E(u[1],u[1],D);E(u[2],u[2],B);E(u[3],u[3],p);E(u[4],u[4],y);E(u[5],u[5],b);E(u[6],u[6],v);E(u[7],u[7],m)}for(r=0;r<8;r+=1){h[2*r]=u[r].h;h[2*r+1]=u[r].l}return h}function C(n,e){this.h=n;this.l=e}function A(n,e){n.h=e.h;n.l=e.l}function s(n,e,t){n.l=e.l>>>t|e.h<<32-t;n.h=e.h>>>t|e.l<<32-t}function w(n,e,t){n.l=e.h>>>t|e.l<<32-t;n.h=e.l>>>t|e.h<<32-t}function F(n,e,t){n.l=e.l>>>t|e.h<<32-t;n.h=e.h>>>t}function E(n,e,t){var r=(e.l&65535)+(t.l&65535);var o=(e.l>>>16)+(t.l>>>16)+(r>>>16);var f=(e.h&65535)+(t.h&65535)+(o>>>16);var i=(e.h>>>16)+(t.h>>>16)+(f>>>16);n.l=r&65535|o<<16;n.h=f&65535|i<<16}function d(n,e,t,r,o){var f=(e.l&65535)+(t.l&65535)+(r.l&65535)+(o.l&65535);var i=(e.l>>>16)+(t.l>>>16)+(r.l>>>16)+(o.l>>>16)+(f>>>16);var h=(e.h&65535)+(t.h&65535)+(r.h&65535)+(o.h&65535)+(i>>>16);var u=(e.h>>>16)+(t.h>>>16)+(r.h>>>16)+(o.h>>>16)+(h>>>16);n.l=f&65535|i<<16;n.h=h&65535|u<<16}function g(n,e,t,r,o,f){var i=(e.l&65535)+(t.l&65535)+(r.l&65535)+(o.l&65535)+(f.l&65535),h=(e.l>>>16)+(t.l>>>16)+(r.l>>>16)+(o.l>>>16)+(f.l>>>16)+(i>>>16),u=(e.h&65535)+(t.h&65535)+(r.h&65535)+(o.h&65535)+(f.h&65535)+(h>>>16),a=(e.h>>>16)+(t.h>>>16)+(r.h>>>16)+(o.h>>>16)+(f.h>>>16)+(u>>>16);n.l=i&65535|h<<16;n.h=u&65535|a<<16}},RMD160:function(n){var t=n&&typeof n.uppercase==="boolean"?n.uppercase:false,i=n&&typeof n.pad==="string"?n.pda:"=",h=n&&typeof n.utf8==="boolean"?n.utf8:true,u=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],a=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],l=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],C=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11];this.hex=function(n){return f(A(n,h))};this.b64=function(n){return B(A(n,h),i)};this.any=function(n,e){return D(A(n,h),e)};this.raw=function(n){return A(n,h)};this.hex_hmac=function(n,e){return f(s(n,e))};this.b64_hmac=function(n,e){return B(s(n,e),i)};this.any_hmac=function(n,e,t){return D(s(n,e),t)};this.vm_test=function(){return hex("abc").toLowerCase()==="900150983cd24fb0d6963f7d28e17f72"};this.setUpperCase=function(n){if(typeof n==="boolean"){t=n}return this};this.setPad=function(n){if(typeof n!=="undefined"){i=n}return this};this.setUTF8=function(n){if(typeof n==="boolean"){h=n}return this};function A(n){n=h?e(n):n;return w(F(c(n),n.length*8))}function s(n,t){n=h?e(n):n;t=h?e(t):t;var r,o,f=c(n),i=Array(16),u=Array(16);if(f.length>16){f=F(f,n.length*8)}for(r=0;r<16;r+=1){i[r]=f[r]^909522486;u[r]=f[r]^1549556828}o=F(i.concat(c(t)),512+t.length*8);return w(F(u.concat(o),512+160))}function w(n){var e,t="",r=n.length*32;for(e=0;e<r;e+=8){t+=String.fromCharCode(n[e>>5]>>>e%32&255)}return t}function F(n,e){var t,f,i,h,c=1732584193,D=4023233417,B=2562383102,A=271733878,s=3285377520,w,F,p,y,b,v,m,x,_,S;n[e>>5]|=128<<e%32;n[(e+64>>>9<<4)+14]=e;h=n.length;for(i=0;i<h;i+=16){w=v=c;F=m=D;p=x=B;y=_=A;b=S=s;for(f=0;f<=79;f+=1){t=r(w,E(f,F,p,y));t=r(t,n[i+u[f]]);t=r(t,d(f));t=r(o(t,l[f]),b);w=b;b=y;y=o(p,10);p=F;F=t;t=r(v,E(79-f,m,x,_));t=r(t,n[i+a[f]]);t=r(t,g(f));t=r(o(t,C[f]),S);v=S;S=_;_=o(x,10);x=m;m=t}t=r(D,r(p,_));D=r(B,r(y,S));B=r(A,r(b,v));A=r(s,r(w,m));s=r(c,r(F,x));c=t}return[c,D,B,A,s]}function E(n,e,t,r){return 0<=n&&n<=15?e^t^r:16<=n&&n<=31?e&t|~e&r:32<=n&&n<=47?(e|~t)^r:48<=n&&n<=63?e&r|t&~r:64<=n&&n<=79?e^(t|~r):"rmd160_f: j out of range"}function d(n){return 0<=n&&n<=15?0:16<=n&&n<=31?1518500249:32<=n&&n<=47?1859775393:48<=n&&n<=63?2400959708:64<=n&&n<=79?2840853838:"rmd160_K1: j out of range"}function g(n){return 0<=n&&n<=15?1352829926:16<=n&&n<=31?1548603684:32<=n&&n<=47?1836072691:48<=n&&n<=63?2053994217:64<=n&&n<=79?0:"rmd160_K2: j out of range"}}};(function(e,t){var r=false;if(typeof exports==="object"){r=exports;if(exports&&typeof global==="object"&&global&&global===global.global){e=global}}if(typeof define==="function"&&typeof define.amd==="object"&&define.amd){define(function(){return n})}else if(r){if(typeof module==="object"&&module&&module.exports===r){module.exports=n}else{r.Hashes=n}}else{e.Hashes=n}})(this)})();

@@ -1,36 +0,23 @@

{
"name" : "jshashes"
, "description" : "A fast and independent hashing library pure JavaScript implemented (ES3 compliant) for both server and client side (MD5, SHA1, SHA256, SHA512, RIPEMD, HMAC and Base64)"
, "keywords" : [ "hash", "md5", "sha1", "sha256", "hashes", "sha512", "RIPEMD", "base64", "hmac", "crc", "encoding", "algorithm" ]
, "version" : "1.0.4"
, "maintainers" : [
{
"name": "jshashes",
"description": "A fast and independent hashing library pure JavaScript implemented (ES3 compliant) for both server and client side (MD5, SHA1, SHA256, SHA512, RIPEMD, HMAC and Base64)",
"version": "1.0.5",
"repository": "h2non/jshashes",
"author": "Tomas Aparicio <tomas@aparicio.me>",
"contributors": [
{
"name": "Tomas Aparicio",
"email": "tomas@aparicio.me",
"web": "http://tomas.aparicio.me"
}
]
, "contributors": [
{
"name": "C. Scott Ananian",
"email": "cscott@cscott.net",
"web": "http://cscott.net"
}
]
, "repository" : {
"type" : "git",
"url" : "http://github.com/h2non/jshashes.git"
}
, "homepage": "https://github.com/h2non/jshashes"
, "dependencies": {}
, "devDependencies": {
"mocha": "~1.9.0"
}
, "bugs" : { "url" : "http://github.com/h2non/jshashes/issues" }
, "engines" : { "node" : "*", "browser": "*"}
, "main" : "hashes"
, "bin": {
"hashes": "./bin/cli.js"
}
, "licenses": [
}
],
"engines": {
"node": "*",
"browser": "*"
},
"main": "hashes",
"bin": {
"hashes": "./bin/hashes"
},
"licenses": [
{

@@ -40,13 +27,27 @@ "type": "New BSD",

}
]
, "directories": {
],
"directories": {
"test": "test"
}
, "scripts": {
},
"scripts": {
"test": "mocha"
}
, "demos": [
"/examples/client/hexadecimal.html",
"/examples/client/benchmark.html"
},
"devDependencies": {
"mocha": "~1.9.0",
"uglify-js": "~2.4.13"
},
"keywords": [
"hash",
"md5",
"sha1",
"sha256",
"hashes",
"sha512",
"RIPEMD",
"base64",
"hmac",
"crc",
"encoding",
"algorithm"
]
}

@@ -1,10 +0,15 @@

# jsHashes
# jsHashes
[![Build Status](https://travis-ci.org/h2non/jshashes.png)](https://travis-ci.org/h2non/jshashes)
[![NPM version](https://badge.fury.io/js/jshashes.png)](http://badge.fury.io/js/jshashes)
A fast and independent hashing library pure JavaScript implemented for both server and client side
[![NPM](https://nodei.co/npm/jshashes.png?stars&downloads)](https://nodei.co/npm/jshashes/)
# About
`jsHashes` is a pure JavaScript implementation of the most extended hash algorithms.
`jshashes` is a pure JavaScript implementation of the most extended hash algorithms.
Its goal is to provide an independent, fast and easy solution for hash algorithms both for client-side and server-side JavaScript environments.
The code is fully compatible with the ECMAScript language specification version 3 and was tested in all major browsers (client-side) and node.js (server-side).
The code is fully compatible with the ECMAScript language specification version 3 and was tested in all major browsers (client-side) and node.js (server-side).

@@ -37,3 +42,3 @@ If you are looking for a high low-level performance on the server-side, note that Node.js provides its own C++ native module ([Crypto](http://nodejs.org/api/crypto.html)).

Following some software design patterns, `jsHashes` implements an object-oriented class-based paradigm for an easy and clean use.
Following some software design patterns, `jsHashes` implements an object-oriented class-based paradigm for an easy and clean use.
Each algorithm has its respective own `class`, providing encapsulation and low coupling between classes.

@@ -53,3 +58,3 @@

// new RIPEMD-160 instace
var RMD160 = new Hashes.RMD160;
var RMD160 = new Hashes.RMD160;
```

@@ -79,3 +84,3 @@

<script type="text/javascript">
// sample string
// sample string
var str = 'This is a sample text!';

@@ -148,3 +153,3 @@ // new MD5 instance and hexadecimal string encoding

* `hex(string)` - Hexadecimal hash encoding from string.
* `hex(string)` - Hexadecimal hash encoding from string.
* `b64(string)` - Base64 hash encondig from string.

@@ -156,3 +161,3 @@ * `any(string,encoding)` - Custom hash algorithm values encoding.

* `vm_test()` - Simple self-test to see is working. Returns `this` Object.
* `setUpperCase(boolean)` - Enable/disable uppercase hexadecimal returned string. Returns `this` Object.
* `setUpperCase(boolean)` - Enable/disable uppercase hexadecimal returned string. Returns `this` Object.
* `setPad(string)` - Defines a custom base64 pad string. Default is '=' according with the RFC standard. Returns `this` Object.

@@ -169,3 +174,3 @@ * `setUTF8(boolean)` - Enable/disable UTF-8 character encoding. Returns `this` Object.

Node.js 0.6.18 running on a VPS Intel I7 930 with 512 MB of RAM (see `server/benchmark.js`)
Node.js 0.6.18 running on a VPS Intel I7 930 with 512 MB of RAM (see `server/benchmark.js`)

@@ -194,3 +199,3 @@ ```javascript

* It has not been planned to include support for more hash algorithms.
* The goal is to provide the same JavaScript code in both server and client side, so it isn't planned to improve it in other ways.
* The goal is to provide the same JavaScript code in both server and client side, so it isn't planned to improve it in other ways.
* Only Node.js server-side was tested, so with minimal changes, you can setup `jsHashes` in other server-side JS environment.

@@ -205,4 +210,4 @@

- Important bugfixes to UTF-8 encoding (broken in 1.0.2) and the RIPEMD-160 hash (broken in 1.0.1). (gh #6)
- New test suite for hashes, CRC32, and hmac; run with 'npm test' in node.
- Fixed global variable leaks. (gh #13)
- New test suite for hashes, CRC32, and hmac; run with 'npm test' in node.
- Fixed global variable leaks. (gh #13)
- CRC32 will now always return positive values. (gh #11)

@@ -236,15 +241,15 @@ - Added package version property to the exposed Hashes Object

- Added CRC-32 calculation support
- Added URL encode/decode helpers functions
* `0.1.2b`
- SHA1 error fixed.
- General code changes (renaming classes, private methods, new methods...).
- Changing library namespace to 'Hashes'.
- Starting code documentation.
- Added new examples of how to use.
* `0.1.1b`
- Minimal library improvements.
- Added URL encode/decode helpers functions
* `0.1.2b`
- SHA1 error fixed.
- General code changes (renaming classes, private methods, new methods...).
- Changing library namespace to 'Hashes'.
- Starting code documentation.
- Added new examples of how to use.
* `0.1.1b`
- Minimal library improvements.
- There has been added some samples, like how to use it and support for NPM package.
* `0.1.0b`
* `0.1.0b`
- First release: the code is stable, but the library is still beta and must be improved and documented.
## TODO

@@ -254,3 +259,3 @@

## Authors
## Authors

@@ -257,0 +262,0 @@ ### Library author

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc