MCPcopy
hub / github.com/angular/angular / _sha1

Function _sha1

packages/service-worker/cli/sha1.ts:31–57  ·  view source on GitHub ↗
(words32: number[], len: number)

Source from the content-addressed store, hash-verified

29}
30
31function _sha1(words32: number[], len: number): string {
32 const w: number[] = [];
33 let [a, b, c, d, e]: number[] = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
34
35 words32[len >> 5] |= 0x80 << (24 - (len % 32));
36 words32[(((len + 64) >> 9) << 4) + 15] = len;
37
38 for (let i = 0; i < words32.length; i += 16) {
39 const [h0, h1, h2, h3, h4]: number[] = [a, b, c, d, e];
40
41 for (let j = 0; j < 80; j++) {
42 if (j < 16) {
43 w[j] = words32[i + j];
44 } else {
45 w[j] = rol32(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
46 }
47
48 const [f, k] = fk(j, b, c, d);
49 const temp = [rol32(a, 5), f, e, k, w[j]].reduce(add32);
50 [e, d, c, b, a] = [d, c, rol32(b, 30), a, temp];
51 }
52
53 [a, b, c, d, e] = [add32(a, h0), add32(b, h1), add32(c, h2), add32(d, h3), add32(e, h4)];
54 }
55
56 return byteStringToHexString(words32ToByteString([a, b, c, d, e]));
57}
58
59function add32(a: number, b: number): number {
60 return add32to64(a, b)[1];

Callers 2

sha1Function · 0.70
sha1BinaryFunction · 0.70

Calls 6

reduceMethod · 0.80
rol32Function · 0.70
fkFunction · 0.70
add32Function · 0.70
byteStringToHexStringFunction · 0.70
words32ToByteStringFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…