def caesar_encrypt(plaintext, shift):
ciphertext = ""
shift_amount = shift % 26
for char in plaintext:
if char.isalpha():
base = ord('a') if char.islower() else ord('A')
shifted = (ord(char) - base + shift_amount) % 26
ciphertext += chr(base + shifted)
else:
ciphertext += char
return ciphertext
def caesar_decrypt(ciphertext, shift):
return caesar_encrypt(ciphertext, -shift)
def brute_force_crack(ciphertext):
results = []
for shift in range(1, 26):
decrypted = caesar_encrypt(ciphertext, -shift)
results.append(f" {shift}: {decrypted}")
return results