Write the three functions to implement the linear

Assignment Help Computer Engineering
Reference no: EM132112797

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))

Reference no: EM132112797

Questions Cloud

Create a python program that takes as a cipher-text : Write a python program that takes as a cipher-text, decrypts the cipher-text as described above and returns the message.
Write a program that plays the tic-tac-toe game : Write a program that plays the tic-tac-toe game. Two players take turns clicking an available cell in a 3 x 3 grid with their respective tokens .
Prevent loss of revenue due to used product markets : Suppose that in order to prevent loss of revenue due to used product markets, smart phone providers successfully lobby the government to make it illegal to buy
Display the amounts after the first five years : When money is invested at 5% interest compounded annually, the amount at the end of each year is 1.05 times the amount at the beginning of that year.
Write the three functions to implement the linear : Write the three functions to implement the linear cipher below, these were shift ciphers.
Stock market crashes are often followed by economic downturn : Stock market crashes are often followed by economic downturns. How does a stock market crash has the potential to lead to a recession in an economy?
Difference between monochronic and polychronic cultures : Explain the difference between monochronic and polychronic cultures. Then, give example of how each culture would differ its response to two business situations
Write an expression for the number of single dollars : Write an expression for the number of single dollars that would have to be paid.
What increase was that : What % increase was that? Briefly discuss the main reasons for this increase.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd