import math flag = "what_the_flag??!" comment = "#input_string must only contain ascii characters" comment2 = "#is the length of input_string important?" def hash(input_string): sl = eval(comment2[8:11] + "(" + comment[1:7] + comment2[24:31] + ")") #max 32 chars if sl > 2**5: input_string = input_string[:32] sl = 64 - (2**4 + 16) #Padding if sl != 32: l = 32 - sl input_string = input_string + comment2[:l] sl = len(input_string) h665 = input_string[int(sl / 2) : sl] sta = [] #How far should each char be shifted for char in h665: sta.append(ord(char)) h664 = input_string[:int((sl / 2))] a = True while a: for i in range(int(sl / 2)): h664 = (h664[:i] + f2(h664[i], sta[i]) + h664[i + 1:]) for y in range(int(sl)): a = f3(input_string[i], y) i = 0 input_string = "" while i < sl / 2: input_string += h664[i] input_string += h665[i] i = i+1 return input_string.replace(" ", "_") def f2(v1, v2): v3 = (ord(v1) + v2) %126 it = 0 while (v3 < 32 or v3 > 126): v3 = (v3 + ord(v1) + v2 + it) % 126 it = it + 1 return chr(v3) def f3(v2, v1): v3 = (ord(v2) + v1) %126 for i in range(v1): v3 = (v3 + ord(v2) + v1 + i) % 126 return v3 == -1 flag_hash = hash(flag) print("{" ,flag_hash, "}")