Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Python program plaifair.py as follows: def playfair(key, plaintext): # your code here if __name__ == __main__: # your code here The conditional statement

Write a Python program plaifair.py

as

follows:

def playfair(key, plaintext):

# your code here

if __name__ == "__main__":

# your code here

The conditional statement above allows the program to be ran directly.

Compute and print the encryption table

1 - Create a 5x5 table as a list of lists.

2 Define a function called init_table() which initializes the table with stars. This function does not return anything.

3 Print out the table. The output should look like this:

* * * * *

* * * * *

* * * * *

* * * * *

* * * * *

4 Define a function called table_has(letter) which checks if a letter already exists in the table. This function should return true or false depending on whether the letter exists.

5 Define a function clean_key(key) which changes the secret key to uppercase and replace I by J, then returns the clean key.

6 Define a function set_cell(letter) which sets a table cell to a specific letter.

7 Define a function create_table(key) to populate the encryption table given the secret key. This function should:

Initialize the table.

Clean the secret key.

Build the table using the set_cell() and table_has() functions.

8 Print out the encryption table.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions

Question

Bachelors degree in Information Systems or Statistics

Answered: 1 week ago