Created
March 12, 2020 09:46
-
-
Save jedhodson/98f9b32740917eebb690b92020f7c337 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
# ASCII - SHA3-512 - any | |
# Sudo>EngSoc xx | |
import hashlib | |
import base64 | |
import random | |
import string | |
#INPUT_STRING = "Sudo>EngSoc," | |
INPUT_STRING = "Sudo, better than Eng Soc " | |
SEARCH_TERM = "Sudo" | |
ALLOWED_CHARACTERS = string.ascii_letters + string.digits | |
NUMBER_OF_CHARACTERS = len(ALLOWED_CHARACTERS) | |
def characterToIndex(char): | |
return ALLOWED_CHARACTERS.index(char) | |
def indexToCharacter(index): | |
if NUMBER_OF_CHARACTERS <= index: | |
raise ValueError("Index out of range.") | |
else: | |
return ALLOWED_CHARACTERS[index] | |
def next(string): | |
if len(string) <= 0: | |
string.append(indexToCharacter(0)) | |
else: | |
string[0] = indexToCharacter((characterToIndex(string[0]) + 1) % NUMBER_OF_CHARACTERS) | |
if characterToIndex(string[0]) == 0: | |
return list(string[0]) + next(string[1:]) | |
return string | |
#print(base64.b32encode(hash)) | |
#print(getRandCharOfLength(2)) | |
class color: | |
PURPLE = '\033[95m' | |
CYAN = '\033[96m' | |
DARKCYAN = '\033[36m' | |
BLUE = '\033[94m' | |
GREEN = '\033[92m' | |
YELLOW = '\033[93m' | |
RED = '\033[91m' | |
BOLD = '\033[1m' | |
UNDERLINE = '\033[4m' | |
END = '\033[0m' | |
def main(): | |
sequence = list() | |
foundFlag = True | |
#print(base64.b64encode(hashlib.sha384('Sudo, better than Eng Soc jdXla'.encode('ascii')).digest())) | |
while foundFlag: | |
sequence = next(sequence) | |
testString = INPUT_STRING + "".join(sequence) | |
#hash = hashlib.sha3_512(testString.encode('ascii')).digest() | |
hash = hashlib.sha3_384(testString.encode('ascii')).digest() | |
#testHash = hashlib.md5(testString.encode('ascii')).hexdigest() | |
#enc = base64.b32encode(hash) | |
enc = base64.b64encode(hash) | |
result = str(enc).find(SEARCH_TERM, 4, 10) | |
slen = len(SEARCH_TERM) | |
if result != -1: | |
print("" + testString + "") | |
encstr = str(enc) | |
print(encstr[:result] + color.UNDERLINE + encstr[result:result+slen] + color.END + encstr[result+slen:]) | |
print() | |
#input() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment