#暗号生成開始 while place <= len(message)-1: #tionとingに対応するため、文字列を4文字先読み future_string = message[place:place+5] #あまりスマートではない暗号化処理と先送り処理 if future_string.startswith(("TION")): cryptedmessage.append(crypt_dict["TION"]) place += len("TION") elif future_string.startswith(("ING")): cryptedmessage.append(crypt_dict["ING"]) place += len("ING") #一文字づつ暗号化 else: cryptedmessage.append(crypt_dict[message[place]]) place += 1 #暗号と早見表を送付 print(cryptedmessage)
for crypted_num in cryptedmessage: print(crypted_num + ":"+ crypt_cheatsheet[crypted_num])