Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!