Aim : Implement RSA encryption-decryption algorithm.
C Program Code :
#include <stdio.h>
#include <conio.h>
#include <math.h>
void main()
{
int p,q,m,fn,e,d=0,temp,t1,t2,ci,pl,n;
clrscr();
printf("Enter Prime Number p : ");
scanf("%d",&p);
printf("Enter Prime Number q : ");
scanf("%d",&q);
printf("Enter e : ");
scanf("%d",&e);
printf("Enter m : ");
scanf("%d",&m);
n=p*q;
fn=((p-1)*(q-1));
while(temp!=1);
{
d++;
temp=(d*e)%fn;
}
printf("\nn : %d",n);
printf("\nfn : %d",fn);
printf("\nd : %d",d);
ci=((long long int)pow(m,e)%n);
printf("\nEncrypted Text : %d",ci);
pl=((long int)pow(ci,d))%n;
printf("\nDecrypted Text : %d",pl);
getch();
}
Output :
0 Comments