Question: How I design a Python code that encrypts and decrypts a message using the RSA crypto scheme? My basic format is: 1. Prompt user for
How I design a Python code that encrypts and decrypts a message using the RSA crypto scheme?
My basic format is:
1. Prompt user for a public key, followed by the message he wants encrypted.
2. Display the ciphered text.
3. Prompt the user for the ciphered text and the private key. (For debugging purposes, I am having the user manually type in the message)
4. Output the deciphered message.
Here is my code so far, although it is primarily the back end. I understand how RSA works but need help with practical implementation.
def gcd(a,b): if b==0: return a else: return gcd(b,a%b) #reading inputs from user p = int(input('Enter the value of p = ')) q = int(input('Enter the value of q = '))
#calculating n valaue n = p*q
#calculating t value where t = t = (p-1)*(q-1)
#finding e value for e in range(2,t): if gcd(e,t)== 1: break
#finding d value for i in range(1,10): x = 1 + i*t if x % e == 0: d = int(x/e) break #printing public and private key value print("public key = (",e,",",n,")") print("private key = (",d,",",n,")")
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
