•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 392,092 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,897 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser:
Views: 919 | Replies: 1
![]() |
Hey Every Body can u PLease help me with this this is a code 4 RSA it is workin' for small values of {p,q,e} like {11,3,7} but it does'nt work for {11,17,7} Please help me at this POint even long double is not enough for storing the value of c[i]^d if c[i]=171 and d=23
#include<conio.h>
#include<math.h>
int funct(char p)
{
int x;
if(p>='a'&&p<='z')
x=p-96;
if(p>='A'&&p<='Z')
x=p-64;
return x;
}
void main()
{
int i,p,q,n,z,e,s,c[30],p2[30],flag[30],tra;
float l,d;
long double x,y;
unsigned long int div,div1;
char pra[30];
clrscr();
printf("Enter the Values of P & Q");
scanf("%d%d",&p,&q);
n=p*q;
z=(p-1)*(q-1);
printf("Enter the Encryption key");
scanf("%d",&e);
l=1*(abs(z));
d=ceil(l/e);
printf("Enter The Plain Text");
scanf("%s",pra);
for(i=0;i<strlen(pra);i++)
{
flag[i]=0;
if(pra[i]>='a'&&pra[i]<='z')
flag[i]=1;
else
continue;
}
printf("Encryption\n");
for(i=0;i<strlen(pra);i++)
{
s=funct(pra[i]);
x=pow(((long double)s),((long double)e));
div=(unsigned long int)x;
c[i]=div%n;
printf("%d ",c[i]);
}
printf("\nDecryption\n");
for(i=0;i<strlen(pra);i++)
{
tra=c[i];
y=pow(((long double)tra),((long double)d));
div1=(unsigned long int)y;
p2[i]=div1%n;
if(flag[i]==0)
printf("%c ",(p2[i]+64));
else
printf("%c ",(p2[i]+96));
}
getch();
} Praneeth Kumar
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb C Marketplace
- Code 19 Registry Error (Windows NT / 2000 / XP / 2003)
- Why won't this code work? (VB.NET)
- Need help with DirectX code (C)
- Tutorials & Code Submissions - Questions? (DaniWeb Community Feedback)
- Some Basic Code Hopefully (Help Needed) (HTML and CSS)
Other Threads in the C Forum
- Previous Thread: Help for newbie
- Next Thread: need help for address book program in Turbo C not C++..



Linear Mode