Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

Students also viewed these Databases questions

Question

=+impact member states and MNEs?

Answered: 1 week ago