Answered step by step
Verified Expert Solution
Question
1 Approved Answer
prompt(s) transportation cipher.py Python Learning Objective: To implement functions and write an algorithms to encrypt and decrypt plaintext. Substitution cipher is another encryption method that
prompt(s) transportation cipher.py Python Learning Objective: To implement functions and write an algorithms to encrypt and decrypt plaintext. Substitution cipher is another encryption method that works by substituting one letter for another one throughout a message Part 1: Implement Functions Open this file: Transposition Ciphery This has a program that encrypts and decrypts a message using transposition cipher, your task is to take the algorithm that encrypts and create a function, and take the algorithm that decrypts and create a function for that one. You should have two functions, one that encrypts and one that decrypts. Test your program by prompting the user for plaintext, encryptit, output the cipher message, and then decrypt it, and output the decrypted message. Part 2 Create a function to reverse the encryption Instruction:Below you are given a function to encrypt a message using a key. Your task is to create a function to reverse the ciphertext back to plain text. In other words, create a function to reverse the algorithm det substitutionEncrypt plaintext, key) alphabet - "abcdefghijklmnoporstuvwxyz plaintext - plaintext. lower() cipher Text for chin plaintext: Idx alphabet.indexch) Cipher Text = CipherText + keylld return cipher Text Part 3 Create a function rot13 to encrypt and decrypt a message During the Roman times Julius Caesar is reported to have encrypted messages to his soldiers and generals by using a simple shift of the alphabet. Every character was encrypted by substituting it with a character that was some fixed number of letters away in the alphabet. this method has been adopted widely and they call it rot 13. The cipher encrypts a message by rotating the plaintext character by 13 positions in the alphabet. The nice thing about rot 13 is that the same function can be used to encrypt and decrypt a message. Create a function to encrypt and decrypt a plaintext message. plaintext = input("Enter a secret message: ") evenchars = "" oddchars charCount = 0 for ch in plaintext: if charCount % 2 == 0: evenchars = evenChars - ch else: oddChars = oddChars + ch charcount = charcount + 1 cipherText = oddChars + evenchars print(cipherText) halflength = len(cipher Text) //2 oddChars = cipher Text[:halflength] =store odds first half evenchars = cipherText[halfLength:] =store even second ha plaintext = "" for i in range (halflength): plaintext += evenCharsil plaintext += oddchars[i] if len(oddChars)
prompt(s)
transportation cipher.py
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started