(words32: number[], len: number)
| 29 | } |
| 30 | |
| 31 | function _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 | |
| 59 | function add32(a: number, b: number): number { |
| 60 | return add32to64(a, b)[1]; |
no test coverage detected
searching dependent graphs…