HMAC of short message using SHA-1 and SHA-256

Benchmark created by Jesse Hallett on


Description

Computes HMAC values for a short set of request headers. HMAC values are useful for verifying request details, for example when submitting OAuth signed requests.

This test uses the jsSHA implementations for SHA-1, SHA-256, and HMAC. http://jssha.sourceforge.net/

Preparation HTML

<script src="http://dl.dropbox.com/u/1115421/scripts/sha.js"></script>
<script>
  var request = 'GET /resource/1 HTTP/1.1\n' + 'Host: example.com\n' + 'Authorization: MAC id="h480djs93hd8",' + 'nonce="274312:dj83hs9s",' + 'mac="kDZvddkndxvhGRXZhvuDjEWhGeE="';
  var key = 'SecretKey';
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
HMAC SHA-1
var shaObj = new jsSHA(request, 'ASCII');
var hmac = shaObj.getHMAC(key, 'ASCII', 'SHA-1', 'HEX');
console.log('HMAC SHA-1 output', hmac);
ready
HMAC SHA-256
var shaObj = new jsSHA(request, 'ASCII');
var hmac = shaObj.getHMAC(key, 'ASCII', 'SHA-256', 'HEX');
console.log('HMAC SHA-256 output', hmac);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.

  • Revision 1: published by Jesse Hallett on
  • Revision 2: published by Jesse Hallett on