examples/plugins/stats/js/sha512.js
function rstr_hmac_sha512(key, data)
{
  var bkey = rstr2binb(key);
  if(bkey.length > 32) bkey = binb_sha512(bkey, key.length * 8);

  var ipad = Array(32), opad = Array(32);
  for(var i = 0; i < 32; i++)
  {
    ipad[i] = bkey[i] ^ 0x36363636;
    opad[i] = bkey[i] ^ 0x5C5C5C5C;
  }

  var hash = binb_sha512(ipad.concat(rstr2binb(data)), 1024 + data.length * 8);
  return binb2rstr(binb_sha512(opad.concat(hash), 1024 + 512));
}
function rstr_hmac_sha512(key, data)
{
  var bkey = rstr2binb(key);
  if(bkey.length > 32) bkey = binb_sha512(bkey, key.length * 8);

  var ipad = Array(32), opad = Array(32);
  for(var i = 0; i < 32; i++)
  {
    ipad[i] = bkey[i] ^ 0x36363636;
    opad[i] = bkey[i] ^ 0x5C5C5C5C;
  }

  var hash = binb_sha512(ipad.concat(rstr2binb(data)), 1024 + data.length * 8);
  return binb2rstr(binb_sha512(opad.concat(hash), 1024 + 512));
}
function rstr_hmac_sha512 ( key , data ) { var bkey = rstr2binb ( key ) ; if ( bkey . length > 32 ) bkey = binb_sha512 ( bkey , key . length * 8 ) ; var ipad = Array ( 32 ) , opad = Array ( 32 ) ; for ( var i = 0 ; i < 32 ; i ++ ) { ipad [ i ] = bkey [ i ] ^ 0x36363636 ; opad [ i ] = bkey [ i ] ^ 0x5C5C5C5C ; } var hash = binb_sha512 ( ipad . concat ( rstr2binb ( data ) ) , 1024 + data . length * 8 ) ; return binb2rstr ( binb_sha512 ( opad . concat ( hash ) , 1024 + 512 ) ) ; }
/*
Calculate the HMAC-SHA-512 of a key and some data (raw strings)
/ * Calculate the HMAC - SHA - 512 of a key and some data ( raw strings )