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

Function core_sha1

example/bundle.js:452–492  ·  view source on GitHub ↗
(x, len)

Source from the content-addressed store, hash-verified

450 * Calculate the SHA-1 of an array of big-endian words, and a bit length
451 */
452 function core_sha1(x, len) {
453 /* append padding */
454 x[len >> 5] |= 0x80 << (24 - len % 32);
455 x[((len + 64 >> 9) << 4) + 15] = len;
456
457 var w = Array(80);
458 var a = 1732584193;
459 var b = -271733879;
460 var c = -1732584194;
461 var d = 271733878;
462 var e = -1009589776;
463
464 for (var i = 0; i < x.length; i += 16) {
465 var olda = a;
466 var oldb = b;
467 var oldc = c;
468 var oldd = d;
469 var olde = e;
470
471 for (var j = 0; j < 80; j++) {
472 if (j < 16) { w[j] = x[i + j]; } else { w[j] = rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1); }
473 var t = safe_add(
474 safe_add(rol(a, 5), sha1_ft(j, b, c, d)),
475 safe_add(safe_add(e, w[j]), sha1_kt(j))
476 );
477 e = d;
478 d = c;
479 c = rol(b, 30);
480 b = a;
481 a = t;
482 }
483
484 a = safe_add(a, olda);
485 b = safe_add(b, oldb);
486 c = safe_add(c, oldc);
487 d = safe_add(d, oldd);
488 e = safe_add(e, olde);
489 }
490 return Array(a, b, c, d, e);
491
492 }
493
494 /*
495 * Perform the appropriate triplet combination function for the current

Callers 4

hex_sha1Function · 0.85
b64_sha1Function · 0.85
str_sha1Function · 0.85
core_hmac_sha1Function · 0.85

Calls 4

rolFunction · 0.85
safe_addFunction · 0.85
sha1_ftFunction · 0.85
sha1_ktFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…