Hi everyone,
I'm trying to code a program that uses RSA to encrypt your message. I assume you know it but if you don't know let me explain simply:
Your enter a word (actually it is a sentence but for now a word) then program will convert letters to numbers (like a=1 m=13 etc.) and group them. Use with all given values n=pq (n is the modulus). C=(m^e) (mod n ) where C is encrypted message m is numbers (converted from letters).
My problem is that it gives warning messages as below.
[IMG]http://i43.tinypic.com/14kbiux.jpg[/IMG]
Since i'm a beginner in C, it may have serious problems i'd be glad if you assist me to fix problems and improve my code.
Thanks
#include <stdio.h>
#include <string.h>
#include <conio.h>
char msg[50];
char *p_msg;
void encrypt(int b[50])
{
int index,n,p=43,q=59,e=13;
n=p*q;
for (index=0;index<strlen(b);index++)
{
b[index]=(pow(b[index],e)) % n;
}
for (index=0;index<strlen(b);index++)
{
printf("Your encrypted message is: \n %d\t",b[index]);
}
}
void convert(char a[50])
{
int valuea[50],index;
for (index=0;index<strlen(a);++index)
{
if (a[index]>='a' && a[index]<='z')
{
valuea[index]=a[index]-'a'+1;
}
}
for (index=0;index<strlen(msg);++index)
{
printf("%d\t",valuea[index]);
}
encrypt(valuea);
}
int main(void)
{
printf("Enter your message: ");
scanf("%s",msg);
p_msg=msg;
convert(msg);
printf("\nYour message was: %s",msg);
getch();
return 0;
}