picoctf/crypto/caesar/solve.py

17 lines
494 B
Python
Executable File

#!/usr/bin/env nix-shell
#!nix-shell -i python3 -p python3
def decrypt(ciphertext: str, key: int):
for letter in ciphertext:
shifted = chr(((ord(letter) - ord('a') + key + 26) % 26) + ord('a'))
print(shifted, end='')
print()
if __name__ == "__main__":
with open('ciphertext') as file:
enc = file.read().strip()[len('picoCTF{'):-len('}')]
# Note: seems to be the last one, "crossing the rubicon"
for shift in range(26):
decrypt(enc, shift)