Question: Problem 2. Write encrypt and decrypt functions for a simple substitution cipher. The key will be a list of integers that represents a permutation of

 Problem 2. Write encrypt and decrypt functions for a simple substitution

Problem 2. Write encrypt and decrypt functions for a simple substitution cipher. The key will be a list of integers that represents a permutation of the set {0, 1, ...,25). You can generate a random key with the following code: G=SymmetricGroup(range (26) f=G.random_element() k=[f(i) for i in range (26)] By the way, here's another way to get a random key: import numpy f=numpy.random. permutation (range (26)) k=list(f) Once you have the encrypt and decrypt functions working and have generated a key, run the following code to show that your program works: A="YAYCRYPTOGRAPHYISSUPERFUN" B=encrypt(A,k) print(B) C=decrypt (B,k) print(C)

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!