/* SAVE THIS TEXT AS FILE setup.js (LOWER CASE)*/
shs_blocksize = 64;
shs_digestsize = 20;
var shsInfo = new Object;
shsInfo.digest = new Array(5);
shsInfo.countLo = 0;
shsInfo.countHi = 0;
shsInfo.data = new Array(16);
var K1 = 0x5A827999; var K2 = 0x6ED9EBA1; var K3 = 0x8F1BBCDC; var K4 = 0xCA62C1D6;
var h0init = 0x67452301; var h1init = 0xEFCDAB89; var h2init = 0x98BADCFE;var h3init = 0x10325476; var h4init = 0xC3D2E1F0;
var h0 = 0;	var h1 = 0;	var h2 = 0;	var h3 = 0;	var h4 = 0;
var A = 0; var B = 0; var C = 0; var D = 0; var E = 0;
var W = new Array(16);
function f1(x,y,z){var result = ((x & y) | (~x & z)); return (result & 0xFFFFFFFF);}
function f2(x,y,z){var result = (x ^ y ^ z); return (result & 0xFFFFFFFF);}
function f3(x,y,z){var result = ((x & y) | (x & z) | (y & z)); return (result & 0xFFFFFFFF);}
function f4(x,y,z){var result = (x ^ y ^ z); return (result & 0xFFFFFFFF);}
function S(n,X) {var result = (((X << n)|(X >>>(32 - n))) & 0xFFFFFFFF); return result;}
function expand(count) {W[count]= W[count-3]^W[count-8]^W[count-14]^W[count-16];W[count] = S(1,W[count]);}
function subRound1(count) { var temp = S(5,A) + f1(B,C,D) + E + W[count] + K1;
E = D; D = C; C = S(30,B); B = A; A = (temp & 0xFFFFFFFF);}
function subRound2(count) { var temp = S(5,A) + f2(B,C,D) + E + W[count] + K2;
E = D; D = C; C = S(30,B); B = A; A = (temp & 0xFFFFFFFF);}
function subRound3(count) { var temp = S(5,A) + f3(B,C,D) + E + W[count] + K3;
E = D; D = C; C = S(30,B); B = A; A = (temp & 0xFFFFFFFF);}
function subRound4(count) { var temp = S(5,A) + f4(B,C,D) + E + W[count] + K4;
E = D; D = C; C = S(30,B); B = A; A = (temp & 0xFFFFFFFF);}
function shsInit() { shsInfo.digest[0] = h0init; shsInfo.digest[1] = h1init;
shsInfo.digest[2] = h2init; shsInfo.digest[3] = h3init; shsInfo.digest[4] = h4init;
shsInfo.countLo = shsInfo.countHi = 0;}
function shsTransform() { for (i = 0; i < 16; i++) W[i] = shsInfo.data[i];
expand(16); expand(17); expand(18); expand(19); expand(20);
expand(21); expand(22); expand(23); expand(24); expand(25);
expand(26); expand(27); expand(28); expand(29); expand(30);
expand(31); expand(32); expand(33); expand(34); expand(35);
expand(36); expand(37); expand(38); expand(39); expand(40);
expand(41); expand(42); expand(43); expand(44); expand(45);
expand(46); expand(47); expand(48); expand(49); expand(50);
expand(51); expand(52); expand(53); expand(54); expand(55);
expand(56); expand(57); expand(58); expand(59); expand(60);
expand(61); expand(62); expand(63); expand(64); expand(65);
expand(66); expand(67); expand(68); expand(69); expand(70);
expand(71); expand(72); expand(73); expand(74); expand(75);
expand(76); expand(77); expand(78); expand(79);
A = shsInfo.digest[0]; B = shsInfo.digest[1]; C = shsInfo.digest[2];
D = shsInfo.digest[3]; E = shsInfo.digest[4];
subRound1(0); subRound1(1); subRound1(2); subRound1(3);
subRound1(4); subRound1(5); subRound1(6); subRound1(7);
subRound1(8); subRound1(9); subRound1(10); subRound1(11);
subRound1(12); subRound1(13); subRound1(14); subRound1(15);
subRound1(16); subRound1(17); subRound1(18); subRound1(19);
subRound2(20); subRound2(21); subRound2(22); subRound2(23);
subRound2(24); subRound2(25); subRound2(26); subRound2(27);
subRound2(28); subRound2(29); subRound2(30); subRound2(31);
subRound2(32); subRound2(33); subRound2(34); subRound2(35);
subRound2(36); subRound2(37); subRound2(38); subRound2(39);
subRound3(40); subRound3(41); subRound3(42); subRound3(43);
subRound3(44); subRound3(45); subRound3(46); subRound3(47);
subRound3(48); subRound3(49); subRound3(50); subRound3(51);
subRound3(52); subRound3(53); subRound3(54); subRound3(55);
subRound3(56); subRound3(57); subRound3(58); subRound3(59);
subRound4(60); subRound4(61); subRound4(62); subRound4(63);
subRound4(64); subRound4(65); subRound4(66); subRound4(67);
subRound4(68); subRound4(69); subRound4(70); subRound4(71);
subRound4(72); subRound4(73); subRound4(74); subRound4(75);
subRound4(76); subRound4(77); subRound4(78); subRound4(79);
shsInfo.digest[0] = (shsInfo.digest[0] + A) & 0xFFFFFFFF;
shsInfo.digest[1] = (shsInfo.digest[1] + B) & 0xFFFFFFFF;
shsInfo.digest[2] = (shsInfo.digest[2] + C) & 0xFFFFFFFF;
shsInfo.digest[3] = (shsInfo.digest[3] + D) & 0xFFFFFFFF;
shsInfo.digest[4] = (shsInfo.digest[4] + E) & 0xFFFFFFFF;}
function shsUpdate() {var bc = 0; var count = buffer.length; var j = 0; var k = 0;
if ((shsInfo.countLo + (count<<3)) < shsInfo.countLo)	shsInfo.countHi++;
shsInfo.countLo += (count<<3); shsInfo.countHi += (count>>>29);
while (count >= shs_blocksize) { for (i = 0; i < 64; i += 4)
shsInfo.data[(i >> 2)] = (buffer.charCodeAt(bc+i)<<24)|(buffer.charCodeAt(bc+i+1) << 16)|
(buffer.charCodeAt(bc+i+2)<<8)|(buffer.charCodeAt(bc+i+3));
shsTransform(); bc += shs_blocksize; count -= shs_blocksize;}
k = (count >>> 2); j = (k << 2); for (i = 0; i < j; i += 4){
shsInfo.data[(i >> 2)] = (buffer.charCodeAt(bc+i)<<24)|(buffer.charCodeAt(bc+i+1) << 16)|
(buffer.charCodeAt(bc+i+2)<<8)|(buffer.charCodeAt(bc+i+3));}
count -=j;
switch (count) { 
case 0: shsInfo.data[k] = 0x80000000; break;
case 1: shsInfo.data[k] = (buffer.charCodeAt(bc+j)<<24)|(0x800000); break;
case 2: shsInfo.data[k] = (buffer.charCodeAt(bc+j)<<24)|(buffer.charCodeAt(bc+j+1) << 16)|(0x8000); break;
case 3: shsInfo.data[k] = (buffer.charCodeAt(bc+j)<<24)|(buffer.charCodeAt(bc+j+1) << 16)|
(buffer.charCodeAt(bc+j+2)<<8)|(0x80); break;	} }
function shsFinal() { var count;  var lowBitcount = shsInfo.countLo;
var highBitcount=shsInfo.countHi;
count = ((shsInfo.countLo >>> 3) & 0x3F); count = (((count >>> 2) + 1));
switch (count) {case 15: shsInfo.data[15] = 0x0;
case 16: shsTransform(); for (i = 0; i < 14; i++) shsInfo.data[i] = 0x0; break;
default: for (i = count; i < 14; i++)	shsInfo.data[i] = 0x0;}
shsInfo.data[14] = highBitcount; shsInfo.data[15] = lowBitcount; shsTransform();}
function hexTextOut() {
var value = new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
var res = '';
for (j = 0; j < 5; j ++) { for (i = 7; i >= 0; i--) {
res += value[((shsInfo.digest[j] >>> (i*4)) &0xF)]; } } return (res);	}