Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.70 KB | None | 0 0
  1. import random
  2.  
  3. def decide(sentence):
  4.     print("do you want to encrypt or decrypt the sentence")
  5.     choice = input()
  6.     if choice == encrypt:
  7.         encrypt(sentence)
  8.     else:
  9.         main()
  10.  
  11.  
  12. def encrypt(sentence):
  13.    
  14.     letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', ' ', ',', '\n']
  15.     value1 = ["c",'d', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z','a', 'b', ' ', ',', '\n']
  16.     value2 = ["d",'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z','a', 'b','c', ' ', ',', '\n']
  17.     value3 = ["e",'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z','a', 'b','c','d', ' ', ',', '\n']
  18.     value4 = ["f",'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z','a', 'b','c','d','e', ' ', ',', '\n']
  19.     value5 = []
  20.  
  21.     final = []
  22.     for character in sentence:
  23.         character = character.replace("~","")
  24.         output = []
  25.         output.append(value1[letters.index(character)])
  26.         output.append(value2[letters.index(character)])
  27.         output.append(value3[letters.index(character)])
  28.         output.append(value4[letters.index(character)])
  29.         x = random.choice(output)
  30.         final.append(x)
  31.  
  32.  
  33.     final = "".join(str(x) for x in final)
  34.     print(final)
  35.     main()
  36.  
  37.  
  38. def main():
  39.     sentence = input("gimme a sentence ")
  40.     try:
  41.         sentence = sentence.lower()
  42.         decide(sentence)
  43.     except:
  44.         print("letters only please")
  45.         main()
  46. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement