Write a class called RSA that will contain all of the functions in the program.
ID: 3904161 • Letter: W
Question
Write a class called RSA that will contain all of the functions in the program. In the constructor for RSA initialize an empty list and set variables e and d to 0. (10 points) • Write a function called inputFunc that reads in the number of entries from the user. Then, read in those many values and add them to the list. (5 points) • Write a function called printFunc that takes in a number and prints "message is " followed by the number. (5 points) • Write a generator function called primeGen that will take a minimum value as a parameter and then yield the next prime numbers. Please note that this input parameter will be quite large and you might want to use long if you're using Python 2. (10 points) • Write a function called keyGen. This function will read in a minimum value from the user. Then, it will use the primeGen generator to get the next 2 prime numbers and generate the value N and the keys e and d. Print e and N but not the other values. (10 points)Explanation / Answer
def inputFunc():
n = int(input("Enter number of entries:"))
list = []
for i in range(n):
a = int(input("Enter number of entries:"))
list.append(a)
return list
def printFunc(a):
print("The message is",n)
def primeGen(a):
while True:
a = a + 1
prime = 1
for i in range(2,a):
if a % i == 0:
prime = 0
break
if prime == 1:
return a
def GCD(x,y):
if x > y:
small = y
else:
small = x
for i in range(1, small+1):
if((x % i == 0) and (y % i == 0)):
gcd = i
return gcd
def keyGen():
n = int(input(("Enter the minimum number:"))
a = primeGen(n);
b = primeGen(a);
N = a*b
tn = (p-1) * (q-1)
e = 0
for i in range(2,tn):
if GCD(i,tn) == 1:
e = i
break
d = (1 + 2*tn)/e
print(e,N)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.