I and trying find a how long it would take to find a collision for an 8 bit hash that executes SHA512. I created a table to store the random hash values and to print the output if there is a collision. Can anyone suggest how I may get my timer to work? Thanks.
import hashlib
import os
import time
lookup_table = {}
collision_counts = 0
for value in range(10):
    random_binary = os.urandom(8)
    result = hashlib.sha512(random_binary).digest()
    result = result[:4]
    if result in lookup_table:
        print("Collision")
        print(random_binary, result)
        print(lookup_table[result], result)
        collision_counts += 1
        timer = time.timer(result)
        print(timer)
    else:
        lookup_table[result] = random_binary
print("Number of collisions:", collision_counts)
 
    