Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

python decryption functions!

I have to create these functions:

3.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 3: Decrypt a single value
def decrypt(c, m, k):
...

4.Write a function called decryptstring that accepts a ciphertext byte string, a multiplier (m), and shift amount (k). It returns an array of integers containing the decrypted values.

# Problem 4: Decrypt a byte string into an array of ints
def decryptstring(ciphertext, m, k):

...

5.Finally, write a function called lineardecipher that accepts a ciphertext byte string, a multiplier (m), and a shift amount (k). It returns the corresponding plaintext byte string.

# Problem 5: Decrypt a byte string, returning a byte string
def lineardecipher(ciphertext, m, k):

...

Also the first two function that I created for this was a function for the Extended Euclidean Algorithm and a Multiplicative inverse function. Here they are:

# 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

If it helps I wrote these encrypting functions in my last assignment:

Write the three functions to implement the linear cipher below, these were shift ciphers.

def linear(b, m, k):
return (b * m + k) % 256

def linearstring(plaintext, m, k):
return [linear(p, m, k) for p in plaintext]

def linearcipher(plaintext, m, k):
return bytes(linearstring(plaintext,m,k))

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M93100265

Have any Question?


Related Questions in Computer Engineering

Language is cgenerate a sparse vector class with operator

Language is C++ Generate a sparse vector class with * operator, such as Vector Vector::operator * (Vector& param) A multiplication (*) operators returns element-wise multiplication of two vectors in another vector. Given ...

Question suppose that we run a greedy search algorithm with

Question : Suppose that we run a greedy search algorithm with h(n) = -g(n). What sort of search will the greedy search emulate? What if h(n) = g(n)? What sort of search does greedy search emulate in this case? Explain yo ...

Is smartart graphic and table slide important for

Is Smartart graphic and Table slide important for PowerPoint Presentation? How would it benefit?

Question introduction to management information systemsread

Question: Introduction to Management Information Systems Read at least three (3) academically reviewed articles on Management Information Systems and complete the following activities: 1. Summarize all three (3) articles ...

Question identify and discuss pros and cons of the

Question: Identify and discuss pros and cons of the webrezpro service compared to a traditional PMS. Please follow the Discussion Rubric to receive credit for posts. The response must be typed, single spaced, must be in ...

Semantic html5an ongoing belief in the web design industry

Semantic HTML5: An ongoing belief in the Web design industry is that HTML5 is critical to Web design for four reasons: Accessibility. Search engine optimization. Faster download speeds. More efficient styling and coding. ...

Take the input of numbers and reverse the order of elements

Take the input of numbers and reverse the order of elements in that vector using recursion.

Write a c functionnbspescapechar s char tnbspthat converts

Write a C function escape(char s[], char t[]) that converts the characters newline and tab into two character sequences n and t as it copies the string t to the string s. Use the C switch statement. Also write the revers ...

Frontier services has a 2000 pure discount bond that comes

Frontier Services has a $2,000 pure discount bond that comes due in one year. The risk-free rate of return is 4 percent. The firm's assets are expected to be worth either $2,800 or $1,600 in one year. Currently, these as ...

Why is formative evaluation importantprovide at least three

Why is formative evaluation important? Provide at least three reasons for using it. What is the difference between formative and summative evaluation? Provide any two types formative evaluation and two types of summative ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As