Question

Python code. NO importing modules. you may not use: contains(), index(), sum(),join(), split(). def column_cipher(plaintext): •...

Python code. NO importing modules. you may not use: contains(), index(), sum(),join(), split().

def column_cipher(plaintext):

• Parameter(s): plaintext ----- a string; the message to be encrypted
• Return value: A string; the ciphertext after applying the column cipher algorithm • Assumptions:

o The standard English alphabet is used: "abcdefghijklmnopqrstuvwxyz"

o All strings will be non-empty, entirely lowercase, and only contain valid letters in the alphabet. • How it works:

o First, transpose the text into 5 different columns by writing each letter from left to right, moving onto the next line after you exhaust all of the columns on a single line. Then, build the cipher text by combining each column from left to right.

For example, with the plaintext: "thequickbrownfoxjumped":
o First, transpose the text into 5 different columns (spaces added for clarity, they are not required):

_

thequ ickbr ownfo xjump e d______

o Now, read each column one at a time:

Column #0: "tioxe" Column #1: "hcwjd" Column #2: "eknu" Column #3: "qbfm" Column #4: "urop"

o Combine the columns from left to right.
§ Your final cipher text is: "tioxehcwjdeknuqbfmurop"

• Examples:
o column_cipher("gotosecretspotatfive") → 'gestocpftroioetvstae' o column_cipher("areyouhungry") → 'aurrhyeuynog'

fence_cipher('asdfjjcmmzkisjdkfpqoerutoqierjsdfmcmmsdjcmdjcmssdfgf'), 'adjcmksdfqeuoirsfcmdcdcsdgsfjmzijkportqejdmmsjmjmsff')

0 0
Add a comment Improve this question Transcribed image text
Answer #1

def column_cipher(plaintext):

ans = ""; i= 0 ; j= 0; res = ""

lst = []

while(i<len(plaintext)):

    j = i

    ans = "";

    while(j <len(plaintext)):

      if j not in lst:

        ans = ans + plaintext[j]

        lst.append(j)

      j = j + 5

    res = res + ans

    i = i + 1

return res

print(column_cipher("thequickbrownfoxjumped"))

#tioxehcwjdeknuqbfmurop

print(column_cipher("gotosecretspotatfive"))

#'gestocpftroioetvstae'

print(column_cipher("areyouhungry"))

#aurrh yeuyn og




===================================================
SEE OUTPUT

Python 3.7.4 (default, Jul 9 2019 06:43) [GCC 6.3.0 20170516] on linux tioxehcwjdeknuqbfmurop gestocpftroioetvstae aurrhyeuyn


Thanks, PLEASE COMMENT if there is any concern.

Add a comment
Know the answer?
Add Answer to:
Python code. NO importing modules. you may not use: contains(), index(), sum(),join(), split(). def column_cipher(plaintext): •...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Part 3: Transposition Ciphers #can't use ord or chr functions You must implement three transposition ciphers...

    Part 3: Transposition Ciphers #can't use ord or chr functions You must implement three transposition ciphers (the "backwards" cipher, the Rail Fence cipher, and the Column Transposition cipher) where the ciphertext is created via an altered presentation of the plaintext. The algorithm for each is detailed in the function descriptions in this section. (13 points) def backwards_cipher(plaintext, key): • Parameter(s): plaintext ----- a string; the message to be encrypted key ----- an integer; the number to control this cipher •...

  • USE C programming (pls label which file is libcipher.h and libcipher.c) Q4) A shift cipher is...

    USE C programming (pls label which file is libcipher.h and libcipher.c) Q4) A shift cipher is one of the simplest encryption techniques in the field of cryptography. It is a cipher in which each letter in a plain text message is replaced by a letter some fixed number of positions up the alphabet (i.e., by right shifting the alphabetic characters in the plain text message). For example, with a right shift of 2, ’A’ is replaced by ’C’, ’B’ is...

  • 1) Echo the input: First, you should make sure you can write a program and have...

    1) Echo the input: First, you should make sure you can write a program and have it compile and run, take input and give output. So to start you should just echo the input. This means you should prompt the user for the plaintext, read it in and then print it back out, with a message such as "this is the plaintext you entered:". [4 points, for writing a working program, echoing the input and submitting the program on the...

  • You will be writing a simple Java program that implements an ancient form of encryption known...

    You will be writing a simple Java program that implements an ancient form of encryption known as a substitution cipher or a Caesar cipher (after Julius Caesar, who reportedly used it to send messages to his armies) or a shift cipher. In a Caesar cipher, the letters in a message are replaced by the letters of a "shifted" alphabet. So for example if we had a shift of 3 we might have the following replacements: Original alphabet: A B C...

  • **DO IT AS PYTHON PLEASE** The Trifid Cipher General Problem Description The Trifid cipher (not to be confused with the...

    **DO IT AS PYTHON PLEASE** The Trifid Cipher General Problem Description The Trifid cipher (not to be confused with the creatures from the classic science-fiction film "The Day of the Triffids") is an algorithm that enciphers a plaintext message by encoding each letter as a three-digit number and then breaking up and rearranging the digits from each letter's encoded form. For this assignment, you will create a set of Python functions that can encode messages using this cipher (these functions...

  • C++ Code

    "For two thousand years, codemakers have fought to preserve secrets while codebreakers have tried their best to reveal them." - taken from Code Book, The Evolution of Secrecy from Mary, Queen of Scots to Quantum Cryptography by Simon Singh.The idea for this machine problem came from this book.You will encrypt and decrypt some messages using a simplified version of a code in the book. The convention in cryptography is to write the plain text in lower case letters and the encrypted text in upper case...

  • In this part, you will complete the code to solve a maze.

    - Complete the code to solve a maze- Discuss related data structures topicsProgramming-----------In this part, you will complete the code to solve a maze.Begin with the "solveMaze.py" starter file.This file contains comment instructions that tell you where to add your code.Each maze resides in a text file (with a .txt extension).The following symbols are used in the mazes:BARRIER = '-' # barrierFINISH = 'F' # finish (goal)OPEN = 'O' # open stepSTART = 'S' # start stepVISITED = '#' #...

  • For this assignment, you will write a program to work with Huffman encoding. Huffman code is...

    For this assignment, you will write a program to work with Huffman encoding. Huffman code is an optimal prefix code, which means no code is the prefix of another code. Most of the code is included. You will need to extend the code to complete three additional methods. In particular, code to actually build the Huffman tree is provided. It uses a data file containing the frequency of occurrence of characters. You will write the following three methods in the...

  • Please try to write the code with Project 1,2 and 3 in mind. And use java language, thank you very much. Create an Edit Menu in your GUI Add a second menu to the GUI called Edit which will have one me...

    Please try to write the code with Project 1,2 and 3 in mind. And use java language, thank you very much. Create an Edit Menu in your GUI Add a second menu to the GUI called Edit which will have one menu item called Search. Clicking on search should prompt the user using a JOptionPane input dialog to enter a car make. The GUI should then display only cars of that make. You will need to write a second menu...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT