2026-07-12 20:22:15 +01:00

30 lines
682 B
Python

# generate.py
# Reproduce the shifting process to generate the challenge string
def shift_letter(letter, shift):
start = ord('A') if letter.isupper() else ord('a')
return chr(start + (ord(letter) - start + shift) % 26)
def generate(plaintext):
out = ""
i = 25 # starting shift
for c in plaintext:
if c in ['{', '}', '_']:
# Not shifted — added directly
out += c
continue
# Apply shift and decrease shift counter
out += shift_letter(c, i)
i -= 1
return out
if __name__ == "__main__":
# Example usage:
flag = "CTF{make_caesar_cipher_great_again}"
print(generate(flag))