i have a given string, let's say 'test123' i calculate the sha1 hash value of the string with and take the first 5 characters:
sha1(teststring.encode("utf-8")).hexdigest()[:5]
now i want to generate a random string that has the same first 5 sha1 hash characters
''.join(random.choice(string.ascii_letters + string.digits + string.punctuation) for _ in range(16))
i have a working solution were i just generate random strings and hash them until i find a matching one.
is there a faster way to achive this?