KHOOR ZRUOG
HELLO WORLD
A simple Caesar cipher challenge from picoCTF. The encrypted message was provided with a hint that the shift value was 3.
Caesar cipher is a substitution cipher where each letter is shifted by a fixed number of positions. With a shift of 3, A becomes D, B becomes E, and so on. To decrypt, we shift backwards by the same amount.
Using a shift of -3 (or +23), we can decrypt the message: K (-3) = H H (-3) = E O (-3) = L O (-3) = L R (-3) = O
def caesar_decrypt(text, shift):
result = ""
for char in text:
if char.isalpha():
ascii_offset = ord('A') if char.isupper() else ord('a')
decrypted_char = chr((ord(char) - ascii_offset - shift) % 26 + ascii_offset)
result += decrypted_char
else:
result += char
return result
message = "KHOOR ZRUOG"
print(caesar_decrypt(message, 3))CTF{caesar_is_weak}