while True: p = (solution + invalid_char) * 2 print(p) r = requests.get("https://aes.cryptohack.org/ctrime/encrypt/" + p.encode('ascii').hex()).json() sample = len(r['ciphertext']) print(sample) for c in chars: print((solution + c) * 2) r = requests.get("https://aes.cryptohack.org/ctrime/encrypt/" + ((solution + c) * 2).encode('ascii').hex()).json() print(len(r['ciphertext'])) if len(r['ciphertext']) < sample: solution += c print(solution) if c == "}": print("Solution Found!", solution) sys.exit() break