def cipher_encryption(): print("Message can only be alphabetic") message = input("Enter message: ").upper() key = 13 encryp_text = "" for i in range(len(message)): temp - ord(message(i)) + key if ord(message(i)) == 32: encryp_text += " " elif temp > 90: temp -= 26 encryp_text +=chr(temp) else: encryp_text += chr(temp) # if-else # for print("Encryption Text: ()".format(encryp_text)) def cipher_decription(): print("Message can only be alphanumeric") message = input("Enter message: ").upper() key = 13 decript_text = "" for i in range(len(message)): temp - ord(message(i)) - key if ord(message(i)) == 32: decryp_text += " " elif temp < 45: temp += 26 decryp_text +=chr(temp) else: decryp_text += chr(temp) # if-else # for print("Decrypted Text: ()".format(decript_text )) def main(): choice = int(input("1. Encryption\n2. Decryption\nChoose(1,2): ")) if choice == 1: print("---Encryption---") cipher_encryption() elif choice == 2: print("---Decription---") cipher_decription() else: print("Invalid Choice") if _name_ == "_main_": main()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question