/* A JavaScript implementation of the SHA family of hashes, as defined in FIPS PUB 180-2 as well as the corresponding HMAC implementation as defined in FIPS PUB 198a Copyright Brian Turek 2008-2014 Distributed under the BSD License See http://caligatio.github.com/jsSHA/ for more information Several functions taken from Paul Johnston */ 'use strict';(function(D){function r(a,d,b){var c=0,f=[0],g="",h=null,g=b||"UTF8";if("UTF8"!==g&&"UTF16"!==g)throw"encoding must be UTF8 or UTF16";if("HEX"===d){if(0!==a.length%2)throw"srcString of HEX type must be in byte increments";h=u(a);c=h.binLen;f=h.value}else if("TEXT"===d)h=v(a,g),c=h.binLen,f=h.value;else if("B64"===d)h=w(a),c=h.binLen,f=h.value;else if("BYTES"===d)h=x(a),c=h.binLen,f=h.value;else throw"inputFormat must be HEX, TEXT, B64, or BYTES";this.getHash=function(a,d,b,g){var h=null, e=f.slice(),m=c,k;3===arguments.length?"number"!==typeof b&&(g=b,b=1):2===arguments.length&&(b=1);if(b!==parseInt(b,10)||1>b)throw"numRounds must a integer >= 1";switch(d){case "HEX":h=y;break;case "B64":h=z;break;case "BYTES":h=A;break;default:throw"format must be HEX, B64, or BYTES";}if("SHA-224"===a)for(k=0;kk/8&&(e[b]&=4294967040);for(m=0;m<=b;m+=1)C[m]=e[m]^909522486,s[m]=e[m]^1549556828;d=q(s.concat(q(C.concat(f),a+c,d)),a+n,d);return h(d,B(l))}}function v(a,d){var b=[],c,f=[],g=0,h;if("UTF8"===d)for(h=0;hc?f.push(c):2048>c?(f.push(192|c>>>6),f.push(128|c&63)):55296>c||57344<=c?f.push(224|c>>>12,128|c>>>6&63,128|c&63):(h+=1,c=65536+((c&1023)<<10|a.charCodeAt(h)&1023),f.push(240|c>>>18,128|c>>>12&63,128| c>>>6&63,128|c&63)),c=0;c>>2)+1>b.length&&b.push(0),b[g>>>2]|=f[c]<<24-g%4*8,g+=1;else if("UTF16"===d)for(h=0;h>>2)+1>b.length&&b.push(0),b[g>>>2]|=a.charCodeAt(h)<<16-g%4*8,g+=2;return{value:b,binLen:8*g}}function u(a){var d=[],b=a.length,c,f;if(0!==b%2)throw"String of HEX type must be in byte increments";for(c=0;c>>3]|=f<<24-c%8*4}return{value:d,binLen:4* b}}function x(a){var d=[],b,c;for(c=0;c>>2)+1>d.length&&d.push(0),d[c>>>2]|=b<<24-c%4*8;return{value:d,binLen:8*a.length}}function w(a){var d=[],b=0,c,f,g,h,l;if(-1===a.search(/^[a-zA-Z0-9=+\/]+$/))throw"Invalid character in base-64 string";c=a.indexOf("=");a=a.replace(/\=/g,"");if(-1!==c&&c