Created
September 18, 2023 13:34
-
-
Save erayaydin/6da4081e7c2593fa3252a2f3047326a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import string | |
import hashlib | |
from itertools import permutations | |
WORD_DIGIT = { | |
"one":1, | |
"two":2, | |
"three":3, | |
"four":4, | |
"five":5, | |
"six":6, | |
"seven":7, | |
"eight":8, | |
"nine":9} | |
TOKENS = [ | |
"one", | |
"two", | |
"three", | |
"four", | |
"five", | |
"six", | |
"seven", | |
"eight", | |
"nine", | |
] + list(string.ascii_lowercase) | |
SEPARATOR = ", " | |
STARTING_TEXT = "The SHA256 for this sentence begins with: " | |
for k in range(2, 6): | |
for perm in permutations(TOKENS, k): | |
sha_start = "" | |
for char in perm: | |
if char in WORD_DIGIT: | |
sha_start += str(WORD_DIGIT[char]) | |
else: | |
sha_start += char | |
test_string = STARTING_TEXT + SEPARATOR.join(perm[:-1]) + ", and " + ''.join(perm[-1:]) + "\n" | |
checksum = hashlib.new("sha256") | |
checksum.update(test_string.encode()) | |
if checksum.hexdigest().startswith(sha_start): | |
print(test_string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment