In C++ or C ONLY PLEASE 1.thefunctionsforRSA: (a)Mappingfunction from todecimald
ID: 3940788 • Letter: I
Question
In C++ or C ONLY PLEASE
1.thefunctionsforRSA:
(a)Mappingfunction from todecimaldigits(SeetextbFigure9.7.(b)andformapping).willtoausedinRSAencryptionanddecryption.
(b)Keythattheinputsofprimeand,andgeneratetheparameters(n, ?(n), e, d),andtheforRSA.Thesub-routines
GCD function to find e: gcd(?(n), e) = 1; 1 < e < ?(n). Since there could be many such e values, you may use gcd to find the first five such e values.
Multiplicative inverse: d = e?1(mod ?(n)). You may use extended Euclidean algorithm to find the first five such d values corresponding to each of five e values (Note: Your multiplicative inverse value should be within [0, ?(n))).
(c)Encryptionfunctionthatofandpublic
(d)functionthatofciphertextand
(e)functionfromdecimaldigitsto
2.Experimentthecorrectnessofprogramusingtheplaintextandprimep =73andq =151:
(a)text:
(b)plaintext:
For each test of your RSA algorithm, you need to output the following information:
(a)RSAinformation:n, ?(n),thefirste,andd
(b)plaintext
(c)setsof:
Public key
Ciphertext
Private key
Plaintext
(d)fromdecimaldigitstoTheoutputfortheinputofisinFigure1.
Explanation / Answer
/* * C++ Program to Implement the RSA Algorithm */ #include #include #include #include using namespace std; long int p, q, n, t, flag, e[100], d[100], temp[100], j, m[100], en[100], i; char msg[100]; int prime(long int); void ce(); long int cd(long int); void encrypt(); void decrypt(); int prime(long int pr) { int i; j = sqrt(pr); for (i = 2; i p; flag = prime(p); if (flag == 0) { cout q; flag = prime(q); if (flag == 0 || p == q) { cout msg; for (i = 0; msg[i] != NULL; i++) m[i] = msg[i]; n = p * q; t = (p - 1) * (q - 1); ce(); coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.