dennoh

Ceasar Cipher challenge

Jan 10th, 2020
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. def encrypter(text, key):
  2.     alph = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ., '
  3.     ciphered_text = ''
  4.     for i in range(len(text)):
  5.         t_numeric_val = alph.index(text[i])
  6.         k_numeric_val = alph.index(key[i])
  7.         c_numeric_val = (t_numeric_val + k_numeric_val) % 29
  8.         ciphered_text += alph[c_numeric_val]
  9. ##        print(text[i],t_numeric_val,key[i], k_numeric_val, ciphered_text)
  10.  
  11.     return ciphered_text
  12.  
  13.  
  14. print(encrypter("ONE IF BY LAND, TWO IF BY SEA.", "THE CELERY STALKS AT MIDNIGHT."))
  15. ## EUI,KJKFMXKSDDJJIVOSHRHEIHYLTX
  16. ##def decrypter(text):
  17. ##    for i
Advertisement
Add Comment
Please, Sign In to add comment