MCPcopy Create free account
hub / github.com/browserify/crypto-browserify / core_hmac_sha1

Function core_hmac_sha1

example/bundle.js:516–529  ·  view source on GitHub ↗
(key, data)

Source from the content-addressed store, hash-verified

514 * Calculate the HMAC-SHA1 of a key and some data
515 */
516 function core_hmac_sha1(key, data) {
517 var bkey = str2binb(key);
518 if (bkey.length > 16) { bkey = core_sha1(bkey, key.length * chrsz); }
519
520 var ipad = Array(16),
521 opad = Array(16);
522 for (var i = 0; i < 16; i++) {
523 ipad[i] = bkey[i] ^ 0x36363636;
524 opad[i] = bkey[i] ^ 0x5C5C5C5C;
525 }
526
527 var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz);
528 return core_sha1(opad.concat(hash), 512 + 160);
529 }
530
531 /*
532 * Add integers, wrapping at 2^32. This uses 16-bit operations internally

Callers 3

hex_hmac_sha1Function · 0.85
b64_hmac_sha1Function · 0.85
str_hmac_sha1Function · 0.85

Calls 2

str2binbFunction · 0.85
core_sha1Function · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…