Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re, string, hashlib
- base = "BK*C4J7*QR22*55"
- hash_expected = "6639983504811d176b0f6aec17609736df4aff6cb02eeafedba65b5105380d95e2aaf00cbc5b58aecd7cfda29f7ef078177b665d9475bab5ca2096d8b18f416f"
- unknown_pos = [m.start() for m in re.finditer("\*", base)]
- def next_perm(cnt):
- alphanum = string.ascii_uppercase + string.digits
- lst = [0] * cnt
- m = 0
- total = len(alphanum) ** cnt
- print("Total permutations: " + str(total))
- while m < total:
- for i in reversed(range(cnt)):
- if lst[i] < ( len(alphanum) - 1 ):
- lst[i] = lst[i] + 1
- break
- else:
- lst[i] = 0
- if (m % 1000) == 0: print('{0:.2f}'.format(float(m / total) * 100.0) + "% ", end="")
- m = m + 1
- yield [alphanum[n] for n in lst]
- def key_from_perm(perm):
- key = list(base)
- i = 0
- for pos in unknown_pos:
- key[pos] = perm[i]
- i = i + 1
- return "".join(key)
- for perm in next_perm(len(unknown_pos)):
- key = key_from_perm(perm)
- if hashlib.sha512(key.encode("ascii")).hexdigest() == hash_expected:
- print("")
- print("Result: " + key)
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement