Skip to content

Commit fb18810

Browse files
authored
SHA256.js: Standardjs fixes
1 parent ab22a0e commit fb18810

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

Hashes/SHA256.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -125,43 +125,43 @@ function SHA256 (message) {
125125

126126
// extend 16 32-bit words to 80 32-bit words
127127
for (let i = 16; i < 64; i++) {
128-
const W1 = words[i - 15]
129-
const W2 = words[i - 2]
128+
const W1 = words[i - 15]
129+
const W2 = words[i - 2]
130130
const R1 = rotateRight(W1, 7)
131131
const R2 = rotateRight(W1, 18)
132132
const R3 = rotateRight(W2, 17)
133133
const R4 = rotateRight(W2, 19)
134134
const S0 = parseInt(R1, 2) ^ parseInt(R2, 2) ^ (parseInt(W1, 2) >>> 3)
135-
const S1 = parseInt(R3, 2) ^ parseInt(R4, 2) ^ (parseInt(W2, 2) >>> 10)
136-
const val = parseInt(words[i - 16], 2) + S0 + parseInt(words[i - 7], 2) + S1
137-
words[i] = pad((val >>> 0).toString(2), 32)
135+
const S1 = parseInt(R3, 2) ^ parseInt(R4, 2) ^ (parseInt(W2, 2) >>> 10)
136+
const val = parseInt(words[i - 16], 2) + S0 + parseInt(words[i - 7], 2) + S1
137+
words[i] = pad((val >>> 0).toString(2), 32)
138138
}
139139

140140
// initialize variables for this chunk
141141
let [a, b, c, d, e, f, g, h] = [H0, H1, H2, H3, H4, H5, H6, H7]
142142

143143
for (let i = 0; i < 64; i++) {
144-
const S1 = [6, 11, 25]
145-
.map(turns => rotateRight(pad(e.toString(2), 32), turns))
146-
.map(bitstring => parseInt(bitstring, 2))
147-
.reduce((acc, curr) => acc ^ curr, 0) >>> 0
148-
const CH = ((e & f) ^ (~e & g)) >>> 0
149-
const temp1 = (h + S1 + CH + K[i] + parseInt(words[i], 2)) >>> 0
150-
const S0 = [2, 13, 22]
151-
.map(turns => rotateRight(pad(a.toString(2), 32), turns))
152-
.map(bitstring => parseInt(bitstring, 2))
153-
.reduce((acc, curr) => acc ^ curr, 0) >>> 0
154-
const maj = ((a & b) ^ (a & c) ^ (b & c)) >>> 0
155-
const temp2 = (S0 + maj) >>> 0
156-
157-
h = g
158-
g = f
159-
f = e
160-
e = (d + temp1) >>> 0
161-
d = c
162-
c = b
163-
b = a
164-
a = (temp1 + temp2) >>> 0
144+
const S1 = [6, 11, 25]
145+
.map(turns => rotateRight(pad(e.toString(2), 32), turns))
146+
.map(bitstring => parseInt(bitstring, 2))
147+
.reduce((acc, curr) => acc ^ curr, 0) >>> 0
148+
const CH = ((e & f) ^ (~e & g)) >>> 0
149+
const temp1 = (h + S1 + CH + K[i] + parseInt(words[i], 2)) >>> 0
150+
const S0 = [2, 13, 22]
151+
.map(turns => rotateRight(pad(a.toString(2), 32), turns))
152+
.map(bitstring => parseInt(bitstring, 2))
153+
.reduce((acc, curr) => acc ^ curr, 0) >>> 0
154+
const maj = ((a & b) ^ (a & c) ^ (b & c)) >>> 0
155+
const temp2 = (S0 + maj) >>> 0
156+
157+
h = g
158+
g = f
159+
f = e
160+
e = (d + temp1) >>> 0
161+
d = c
162+
c = b
163+
b = a
164+
a = (temp1 + temp2) >>> 0
165165
}
166166

167167
// add values for this chunk to main hash variables (unsigned)

0 commit comments

Comments
 (0)