# decrypt the Caesar cipher by brute force
ciphertext = "hpwwozypjzfnclnvpoespnzopjzflcpyzhlyzqqtntlwnzopmcplvpcszhhzfwojzftxaczgpespnlpdlcntaspcezxlvpteslcopcezmcplvcplozyezespypiedepaezqtyozfe"
# Code #2 at https://www.geeksforgeeks.org/python-split-string-into-list-of-characters/
def split(word):
return list(word)
def decrypt(char, offset):
result = ''
if (char.isupper()):
result += chr((ord(char) - offset - 65) % 26 + 65)
else:
result += chr((ord(char) - offset - 97) % 26 + 97)
return result
for i in range(1, 26):
print('offset :', i)
for c in split(ciphertext):
print(decrypt(c,i),end='')
print()
Comments