Find Jobs
Hire Freelancers

Quick Python Assignment

$10-30 USD

Completed
Posted about 10 years ago

$10-30 USD

Paid on delivery
I need 3 functions added to the file: Deciphering a Linear Cipher In the previous assignment you wrote a function called linear that encrypts a number a using the formula (m * a + k) mod n For example, using m = 5, k = 11, n = 256, when you encrypt a = 10, you get the value 61. You can generate all the encrypted values by applying the linear function to the values 0...255. >>> [ linear(5, a, 11) for a in range(0, 256) ] [11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, ...] Notice that there are no duplicates. There is a one-to-one mapping between the input and output values. Therefore, the function can be reversed and a string can be both encrypted and decrypted. To decrypt, we will need to compute the multiplicative inverse of m mod n. For example, if m = 5 and n = 26, the multiplicative inverse i obeys 5i = 1 (mod 26). 4. Write a function called multinv that computes the multiplicative inverse of m mod n. The function accepts two numbers as input (m and n) and returns the multiplicative inverse. The multiplicative inverse can be found using the Extended GCD. Recall that the Extended GCD finds x and y such that ax + by = gcd(a, b). The multiplicative inverse of a mod b is x; the multiplicative inverse of b mod a is y. Return the multiplicative inverse as a positive number, modulo n. That is, the number your function returns should be between 0 and n. 5. Write a function called decrypt that accepts three numbers (m, e, and k, where e is the encrypted value) and returns the corresponding decrypted value (a number). If you use m = 5 and k = 11, you should be able to decrypt each of the numbers in the chart on page 40. You can assume that n = 256. 6. Finally, write a function called lineardecipher that decrypts a byte string. It accepts a byte string as input and returns the decrypted byte string. To test this, use the linearcipher function you wrote last week to produce an encrypted string, then use lineardecipher to get the original string back.
Project ID: 5732994

About the project

3 proposals
Remote project
Active 10 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
a very experienced python developer is ready to get the job done quickly, professionally and with the lowest cost. contact me now and I'll start working right away
$10 USD in 1 day
5.0 (1 review)
1.6
1.6
3 freelancers are bidding on average $17 USD for this job
User Avatar
A proposal has not yet been provided
$30 USD in 0 day
4.9 (16 reviews)
4.7
4.7
User Avatar
A proposal has not yet been provided
$10 USD in 1 day
0.0 (0 reviews)
0.0
0.0

About the client

Flag of UNITED STATES
Los Angeles, United States
5.0
29
Member since Oct 16, 2013

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.