Question: Python Help! Decrypt Function using a Multiplicative inverse function. Here is the code that I have so far, I have a multiplicative inverse function that

Python Help! Decrypt Function using a Multiplicative inverse function.

Here is the code that I have so far, I have a multiplicative inverse function that use an Extended Euclidean Algorithm function. I need to use these the multinv function to create a decrypt function. "Write a function called decrypt that accepts three numbers (c, m, and k) and returns the corresponding plaintext (p) value as a number. You can assume the modulus (n) is 256. You will need to compute the multiplicative inverse of m mod 256 to decipher c."

# Problem 1: Extended Euclidean Algorithm def egcd(a, b): if b == 0: return (1, 0) else: # Calculate q q = a // b # Calculate r r = a % b # Calculate (s, t) by calling egcd(b, r) (s,t) = egcd(b, r) return (t, s-q*t) # Problem 2: Multiplicative Inverse def multinv(a, n): g = egcd(a, n) return g[0] % n

# Problem 3: Decrypt a Single Value

def decrypt(c, m, k):

for testing purpose, running decrypt(80, 5, 11) should return 65

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!