In this entry we are going to code a program that would bruteforce a cipher code and decrypt its message.
Code:
import pyperclip
message = raw_input("Enter message to decrypt: ")
LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
print "Bruteforcing..."
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
print('Attempt #%s: %s' % (key, translated))
To run and test the output, click on this link for video tutorial >>>
Comments