Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This assignments a continuation of lab 2. Here is my lab 2's code. #include using namespace std; typedef long long ll; ll calculate(ll a,ll k,ll

This assignments a continuation of lab 2. Here is my lab 2's code.

#include using namespace std; typedef long long ll; ll calculate(ll a,ll k,ll n)// to calculate a^k mod n { ll res=1;// using binary exponentiaion to calculate a^k mod n in log(n) time while(k) { if(k&1)// if k is odd res=(res*a)%n; a=(a*a)%n; k=k/2; } return res;// return res of a^k mod n } int main() { ll i,a,k,n; for(i=1;i<=4;i++) { cout<<"enter value of a,k,n:";// accept base power mod cin>>a>>k>>n; cout<

For lab 3, write a program to decode a message using public key cryptography based on the RSA cipher. Use the code you wrote in Lab2 to calculate the residues.

The input will be a list of 1, 2 or 3 digit numbers with spaces in between Each number will correspond to an ASCII character. The list may contain up to 100 numbers.

Your program should accept a command line argument (see file below) that is the name of the file where the encrypted message is stored. In other words, I will test the program by invoking the following command:

>yourprog testfile

The output of this program will be your name followed by the decrypted message. Decrypt the message using the formula M =C d mod pq. The parameters needed to do this are specified in the beginning of the test file.

The decoded message will be the ASCII characters corresponding to the decimal values calculated using the formula above. The messages are all somewhat famous quotes followed by the name of the person who said them.

Your program should print out the decoded message. Make sure there are no extraneous characters.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions