Question

Is RSA algorithm is same as Ceaser Cipher Algorithm? if not kindly make simple program of...

Is RSA algorithm is same as Ceaser Cipher Algorithm?
if not kindly make simple program of RSA in c and c++.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

RSA algorithm and Ceaser cipher both are different.

RSA algorithm follows Asymmetric encryption where as Ceaser Cipher follows Symmetric encryption.

Symmetric encryption is a type of encryption where only one key (a secret key) is used to both encrypt & decrypt the data(electronic information).

Asymmetric encryption uses two keys(public key and private key) to encrypt a plain text. A public key(first key) is made freely available to anyone who might want to send you a message. The second private key is kept a secret so that you can only know.

program for RSA in c++:-

#include<iostream>
#include<math.h>
using namespace std;

int GCD(int a, int b) {
int t;
while(1) {
t= a%b;
if(t==0)
return b;
a = b;
b= t;
}
}
int main() {
//take 2 random prime numbers
double p = 13;
double q = 11;
double n=p*q;//calculate product of given 2 prime numbers.
double track;
double phi= (p-1)*(q-1);//calculate phi
double enc=7;//e is used for encrypt
//for checking that 1 < e < phi(n) and gcd(e, phi(n)) = 1; i.e., e and phi(n) are coprime.
while(enc<phi) {
track = GCD(enc,phi);
if(track==1)
break;
else
enc++;
}
//choosing d such that it satisfies d*e = 1 mod phi
double d1=1/enc;
double dec=fmod(d1,phi);//d is used for decrypt
double message = 9;
double c = pow(message,enc); //encrypt the message
double m = pow(c,dec);
c=fmod(c,n);
m=fmod(m,n);
cout<<"Original Message = "<<message;
cout<<"\n"<<"p = "<<p;
cout<<"\n"<<"q = "<<q;
cout<<"\n"<<"n = pq = "<<n;
cout<<"\n"<<"phi = "<<phi;
cout<<"\n"<<"e = "<<enc;
cout<<"\n"<<"d = "<<dec;
cout<<"\n"<<"Encrypted message = "<<c;
cout<<"\n"<<"Decrypted message = "<<m;
return 0;
}

program for RSA in C:-

#include<stdio.h>
#include<math.h>
int GCD(int a, int b) {
int t;
while(1) {
t= a%b;
if(t==0)
return b;
a = b;
b= t;
}
}
int main() {
//take 2 random prime numbers
double p = 13;
double q = 11;
double n=p*q;//calculate product of given 2 prime numbers.
double track;
double phi= (p-1)*(q-1);//calculate phi
double enc=7;//e is used for encrypt
//for checking that 1 < e < phi(n) and gcd(e, phi(n)) = 1; i.e., e and phi(n) are coprime.
while(enc<phi) {
track = GCD(enc,phi);
if(track==1)
break;
else
enc++;
}
//choosing d such that it satisfies d*e = 1 mod phi
double d1=1/enc;
double dec=fmod(d1,phi);//d is used for decrypt
double message = 9;
double c = pow(message,enc); //encrypt the message
double m = pow(c,dec);
c=fmod(c,n);
m=fmod(m,n);
//all double values are adjusted to 3 decimal points.
printf("Original Message = %.3lf",message);
printf("\n p=%.3lf ",p);
printf("\n q=%.3lf ",q);
printf("\n n=%.3lf ",n);
printf("\n phi=%.3lf ",phi);
printf("\n enc=%.3lf ",enc);
printf("\n dec=%.3lf ",dec);
printf("\n encrypted messag=%.3lf ",c);
printf("\n decrypted message=%.3lf ",m);
return 0;
}

Add a comment
Know the answer?
Add Answer to:
Is RSA algorithm is same as Ceaser Cipher Algorithm? if not kindly make simple program of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT