Question
C++ RSA PROGRAM (3 total) Program #1 (called generate.cpp) will create a public and private key. This c++ program must randomly find two unique prime
C++ RSA PROGRAM (3 total)
Program #1 (called generate.cpp) will create a public and private key.
This c++ program must randomly find two unique prime numbers and must assure that numbers are prime
It should perform the calculations to create the public and private keys. The calculations are as follows:
1. Choose two prime numbers. (In the real algorithm, you would choose extremely large prime numbers which, in itself, canbe a challenge.) For this problem, choose prime numbers that are less than 100. Call these numbers p and q.
2. Calculate n = p q
3. Calculate the totient t, such that t=(p-1)(q-1)
4. Choose an integer e such that 1 < e< t and e and t have no common integer factors other than 1.
5. Compute d such that de 1 mod t. In other words, d e= 1 + an integer multiple of t.
6. The public key is the pair (e, n). The private key is the paid (d, n).
7. Encryption formula is: C= Pemod(n) Decryption formula is: P= Cdmod(n)
Must create two files, pub.key and priv.key. The two files should contain the two relevant numbers separated by a space on a single line (e.g. 3 33) where 3 is dand 33is n.
Program #2 (called encrypt.cpp) will take as input a public key and short plaintext program and output cipher text.
Must read the public key from the file pub.key Must take as input an integer between 1 and 50 (this will be the original plain text message) Must output ciphertext
Program #3 (called decrypt.cpp) will take as input a private key and ciphertext and output plaintext.
Must read private key from the file priv.key
Must take as input ciphertext output from program #2
Must output decrypted text
Thanks to anyone who answers!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started