Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
776 B
1
Indexable
Never
import hashlib

def find_near_collisions(stid):
    stid = str(stid)
    n = 34  # Number of bits to match
    buckets = {}
    counter = 0
    collision_found = False

    while not collision_found:
        input_string = stid + str(counter)
        hash_value = hashlib.sha256(input_string.encode()).hexdigest()
        prefix = hash_value[:n // 4]

        if prefix in buckets:
            val1 = buckets[prefix].encode()
            val2 = input_string.encode()
            print(f"Near collision found!")
            print(f"Input 1: {val1}")
            print(f"Input 2: {val2}")
            collision_found = True
        else:
            buckets[prefix] = input_string

        counter += 1

    return (val1, val2)

stid = "12345678"
find_near_collisions(stid=stid)
Leave a Comment