Advertisement
mrScarlett

Brute Force

Dec 4th, 2016
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. message = 'AVNYY'
  2. LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  3.  
  4.  
  5. for key in range(len(LETTERS)):
  6.  
  7.  
  8.     translated = ''
  9.  
  10.    
  11.     for symbol in message:
  12.         if symbol in LETTERS:
  13.             num = LETTERS.find(symbol) # get the number of the symbol
  14.             num = num - key
  15.  
  16.             # handle the wrap-around if num is 26 or larger or less than 0
  17.             if num < 0:
  18.                 num = num + len(LETTERS)
  19.  
  20.             # add number's symbol at the end of translated
  21.             translated = translated + LETTERS[num]
  22.  
  23.         else:
  24.             # just add the symbol without encrypting/decrypting
  25.             translated = translated + symbol
  26.    
  27.  
  28.     print('Key #%s: %s' % (key, translated))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement