# -*- coding:utf-8 -*- from base64 import * flag = open("code.txt").readline() # 讀取密文 for i in range(10): pointer = 0 try: temp = b16decode(flag) except TypeError: pointer = 1 # 指示是否發生TypeError異常 if pointer == 1 or '�' in temp: # 若是解碼方式不對,就會提示TypeError,或者亂碼,發現亂碼中必有'�' pointer = 0 try: temp = b32decode(flag) except TypeError: pointer = 1 if pointer == 1 or '�' in temp: temp = b64decode(flag) flag = temp print flag