cde.py (877B)
1 # Python implementation of the Caesar cipher (decryption script)# 2 # MCD 2020 # 3 import sys 4 5 alphabet_doubled = ["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","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"] 6 7 def decrypt(): 8 de_text = "" 9 for character in en_text: 10 count = 0 11 for alph_car in alphabet_doubled[:26]: 12 count = count + 1 13 if alph_car == character: 14 de_text = de_text + alphabet_doubled[count+value+26] 15 break 16 elif count >= 26: 17 de_text = de_text + character 18 19 print(de_text) 20 21 if( len(sys.argv) > 2 ): 22 value = - (int(sys.argv[1]) + 1) 23 en_text = sys.argv[2].lower() 24 try: 25 decrypt() 26 except: 27 print("Terminated.") 28 else: 29 print("Usage: python cde.py [VALUE] [EN_TEXT]") 30 print("Example: python cde.py 4 \'lipps\'") 31 exit(0)