trash hash works now

This commit is contained in:
Christoph J. Scherr 2023-04-21 23:13:04 +02:00
parent e0cf1b11f6
commit 44b56a2942
Signed by: PlexSheep
GPG Key ID: 25B4ACF7D88186CC
1 changed files with 13 additions and 9 deletions

View File

@ -33,22 +33,18 @@ def trash_hash(input: bytearray) -> bytearray:
# print("block: %s" % block.hex())
# initilaize accumulator A_0 with the following constant values:
A_list = [DEFINED_INITIAL] * n
A = DEFINED_INITIAL
# iterate over blocks
for index, block in enumerate(blocks):
if index == 0:
pass
thing = bytes(by0 ^ by1 for by0, by1 in zip(A_list[index - 1], block))
A_list[index] = bytearray(thing)
print("final thing: %s" % A_list[index])
thing = bytes(by0 ^ by1 for by0, by1 in zip(A, block))
A = bytearray(thing)
A = bytearray(1)
A.pop()
return A
return A.join(A_list)
def main():
def use():
some_bytes = bytearray(b'AAAA');
print("hashed: %s" % some_bytes.hex())
print('='*80)
@ -56,5 +52,13 @@ def main():
print('='*80)
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__":
main()