trash hash works now
This commit is contained in:
parent
e0cf1b11f6
commit
44b56a2942
|
@ -33,22 +33,18 @@ def trash_hash(input: bytearray) -> bytearray:
|
||||||
# print("block: %s" % block.hex())
|
# print("block: %s" % block.hex())
|
||||||
|
|
||||||
# initilaize accumulator A_0 with the following constant values:
|
# initilaize accumulator A_0 with the following constant values:
|
||||||
A_list = [DEFINED_INITIAL] * n
|
A = DEFINED_INITIAL
|
||||||
|
|
||||||
# iterate over blocks
|
# iterate over blocks
|
||||||
for index, block in enumerate(blocks):
|
for index, block in enumerate(blocks):
|
||||||
if index == 0:
|
if index == 0:
|
||||||
pass
|
pass
|
||||||
thing = bytes(by0 ^ by1 for by0, by1 in zip(A_list[index - 1], block))
|
thing = bytes(by0 ^ by1 for by0, by1 in zip(A, block))
|
||||||
A_list[index] = bytearray(thing)
|
A = bytearray(thing)
|
||||||
print("final thing: %s" % A_list[index])
|
|
||||||
|
|
||||||
A = bytearray(1)
|
return A
|
||||||
A.pop()
|
|
||||||
|
|
||||||
return A.join(A_list)
|
def use():
|
||||||
|
|
||||||
def main():
|
|
||||||
some_bytes = bytearray(b'AAAA');
|
some_bytes = bytearray(b'AAAA');
|
||||||
print("hashed: %s" % some_bytes.hex())
|
print("hashed: %s" % some_bytes.hex())
|
||||||
print('='*80)
|
print('='*80)
|
||||||
|
@ -56,5 +52,13 @@ def main():
|
||||||
print('='*80)
|
print('='*80)
|
||||||
print("hashed: %s" % hashed.hex())
|
print("hashed: %s" % hashed.hex())
|
||||||
|
|
||||||
|
def test_collision(a: bytearray, b: bytearray) -> bool:
|
||||||
|
return trash_hash(a) == trash_hash(b)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
payload_a = bytearray(b"AAAA")
|
||||||
|
payload_b = bytearray(random.randbytes(122))
|
||||||
|
print("a: %s\tb: %s" % (trash_hash(payload_a).hex(), trash_hash(payload_b).hex()))
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue