Question: 1 . Find two primes ( p & q ) randomly, defining n as n = p * q 2 . Define phi (
Find two primes p & q randomly, defining n as n pq
Define phi npq
Choose e at random, but such that ephi n and e & phi n are coprimethey share no
common factors, ie: GCDephi n
Define d as the MMI of e mod phi n such that ed mod phi ndone with pow
Publicize e n as the public key, keep d n as your private key.
Discard phi n p q
For use of the created keys, both ends of RSAencryption and decryption are forms of modular
exponentiation, either me mod n c or cd mod n m which are both very similar.
note that n is used in both processes, while e and d are exclusive and inverses of each
other
Encryption:
Given: man integere nthe public key of the pair
Return: c a ciphered integer defined as c me mod n
Decryption:
Given: ca ciphered integer formed from the public keyd nthe private key of the pair
Return: m
Your task is to implement those properties into a single, cohesive code that performs RSA
encryption, such that it is abstracted as someone desiring to use RSA would prefer, instead of
having to manually implement it every time. There should be a key generation, encryption, and
decryption method.
Implement recursive gcd function
Implement Inverse Module function
Implement generateKeys function
Implement encrypt and decrypt function
SUBMIT : YOUR CODE AND Check if your code producing the encrypted and
decrypted message for the numbers below: p q and e d and m
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
