0% found this document useful (0 votes)
26 views1 page

RSA Algorithm Implementation in MATLAB

The document describes the RSA encryption algorithm. It prompts the user to input two prime numbers, calculates the public and private keys from those numbers, and displays the keys. The public key consists of the encryption exponent and modulus, while the private key contains the decryption exponent and modulus.

Uploaded by

sandesh2429
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views1 page

RSA Algorithm Implementation in MATLAB

The document describes the RSA encryption algorithm. It prompts the user to input two prime numbers, calculates the public and private keys from those numbers, and displays the keys. The public key consists of the encryption exponent and modulus, while the private key contains the decryption exponent and modulus.

Uploaded by

sandesh2429
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

RSA algorithm

Program:
clear all;
close all;
clc;

p=input('Enter first prime no: ');


q=input('Enter second prime no: ');

n=p*q;
fi=(p-1)*(q-1);
disp(fi);
j=1;
for i=2:fi-1
if gcd(fi,i)==1
a(j)=i;
j=j+1;

end

end
disp(a);
e=input('Enter value of e from above array: ');
for j=3:70
x=j*e;
y=rem(x,fi);
if y==1
d=i;
end
end
disp(d);
disp(e);
PU=[e n];
PR=[d n];
disp(PU);
disp(PR);

Output:
Enter first prime no: 7
Enter second prime no: 11
60

7 11 13 17 19 23 29 31 37 41 43 47 49 53 59

Enter value of e from above array: 41


59

41

41 77

59 77

You might also like