Ash's Blog

CN Lab Prog —>>> RSA

Posted on: March 8, 2011

/*RSA algorithm */
#include <stdio.h>

#include <conio.h>

#include <ctype.h>

#include <math.h>

#include <string.h>

void main()

{

int a,b,i,j,t,x,n,k=0,flag=0,prime[100];

char m[20],pp[20];

float p[20],c[20];

double e,d;

clrscr();

for(i=0;i<50;i++)

{

flag=0;

for(j=2;j<i/2;j++)

if(i%j==0)

{

flag=1;   break;

}

if(flag==0)

prime[k++]=i;

}

a=prime[k-1];

b=[rime[k-2];

n=a*b;

e=(double)prime[2];

d=1/(float)e;

pf(“\nKey f encrytion is: %lf”,d);

pf(“\n Enter the Text:”);

sf(“%s”,&m);

x=strlen(m);

pf(“\nSource—Detination”);

pf(“\nchar\tnumeric\tcipher\tnumeric\tchar\n”);

for(i=0;i

{

pf(“%c”,m[i]);

pf(“\t%d”,m[i]-97);

c[i]=pow(m[i]-97,(float)e);

c[i]=fmod(c[i],(float)n);

pf(“\t%f”,c[i]);

p[i]=pow(c[i],(float)d);

p[i]=fmod(p[i],(float)n);

pf(“\t%f”,p[i]);

pp[i]=p[i]+97;

pf(“\t%c\n”,pp[i]);

}

getch();

}

 

(for DES click here)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow up !

Enter your email address to follow this blog and receive notifications of new posts by email.

iTweet :

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

Where are you?

%d bloggers like this: