Question: In this problem, you will implement the RSA cryptosystem in Python, the most popular public - key cryptosystem used for secure data transmission. Remember that
In this problem, you will implement the RSA cryptosystem in Python, the most popular publickey cryptosystem used for secure data transmission. Remember that you need four parameters to implement this p q e and d as explained in the class.
Things to do:
Prime Number Selection:
You are given a text file 'primes.txt that contains prime numbers between and
Randomly select two prime numbers p and q from this file.
RSA Key Generation:
Write a function rsakeygen.
Calculate mathrmnmathrmpmathrmq where n is the modulus for both the public and private keys.
Calculate Euler's Totient function, varphinpq
Set mathbf
Compute the private key d using the Extended Euclidean Algorithm d equiv ewedgebmod phin A sample python method ExEuclidpy for the Extended Euclidean Algorithm is included in the assignment where the output x represents d See this underlinel i n k for explanation
Encryption
Write a function rsaencrypt that converts each character of the plaintext "Computer" to its ASCII value May use ord in Python
Calculate the Ciphertext: CMebmod n
Decryption
Write a function rsadecrypt that calculates the Plaintext: MCdbmod n
Convert the decrypted ASCII values back to characters to recover the original message.
Displaying Results
Display the generated public and private keys.
Show the encrypted and decrypted version of the plaintext "Computer".
Additional Notes:
You may not use builtin Python RSA or Stream Cipher implementations.
You may write helper functionsmethods if needed. For example, you may need to write a function to calculate the totient value for RSA.
Use good coding practice. Use comments to make your code readable.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
