Skip to content

Instantly share code, notes, and snippets.

@redknight99
Created November 20, 2021 01:58
Show Gist options
  • Save redknight99/ecb30f038f269269f47ad6e1d1c2ae14 to your computer and use it in GitHub Desktop.
Save redknight99/ecb30f038f269269f47ad6e1d1c2ae14 to your computer and use it in GitHub Desktop.
Quick and hacky [Caesar Cipher](https://en.wikipedia.org/wiki/Caesar_cipher) brute force script. Nothing fancy.
# Cesar Cipher Brute Force
def Caesar_Bruteforce(word_string: str) -> None:
if word_string.upper() != word_string:
print("input not upper returning")
return None
message = word_string
LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for key in range(len(LETTERS)):
translated = ''
for symbol in message:
if symbol in LETTERS:
num = LETTERS.find(symbol)
num = num - key
if num < 0:
num = num + len(LETTERS)
translated = translated + LETTERS[num]
else:
translated = translated + symbol
# Manual review message.
message = input('Key #%s: %s' % (key, translated))
if __name__ == "__main__":
Caesar_Bruteforce("KYYGE ZXOV LUATJ COTZKX")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment