Skip to content

Commit 6aeae94

Browse files
committed
everything is an int
1 parent 43fa2ed commit 6aeae94

File tree

2 files changed

+79
-73
lines changed

2 files changed

+79
-73
lines changed

Diff for: sha1-generator.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@
1313
else:
1414
f = "%s ^ %s ^ %s" % (b, c, d)
1515
k = 0xCA62C1D6
16+
17+
if k > 0x80000000:
18+
k = "- 0x%08X" % (0x100000000 - k)
19+
else:
20+
k = "+ 0x%08X" % k
21+
1622
if j < 16:
17-
print "var w%02d:uint = byteInput.readUnsignedInt();" % j,
23+
print "var w%02d:int = byteInput.readInt();" % j,
1824
w_access = "w%02d" % (j % 16)
1925
else:
2026
print "w%02d ^= w%02d ^ w%02d ^ w%02d;" % (j % 16, (j - 3) % 16, (j - 8) % 16, (j - 14) % 16),
2127
w_access = "(w%02d = (w%02d << 1) | (w%02d >>> 31))" % (j % 16, j % 16, j % 16)
22-
print "%s += ((%s << 5) | (%s >>> 27)) + (%s) + 0x%08X + %s;" % (
28+
print "%s += ((%s << 5) | (%s >>> 27)) + (%s) %s + %s;" % (
2329
e, a, a, f, k, w_access),
2430
print "%s = (%s << 30) | (%s >>> 2);" % (b, b, b)

0 commit comments

Comments
 (0)