Hello All,
I am very new to C programming but i was working on cryptography for ipsec and am trying to write a code for implementing a simple code for a stream cipher which will take a 20 charecter long string and a 8 bit seed file and encrypt the text by performing a bit by bit xor operation on the string by generating a random number with same length as text using the seed string.
I know i made some big mistakes but i dont see any compilation errors but i get a runtime error and it just prints the charecters in printf but never accepts any value.
Could anyone kindly help me on this or correct me.
Any help would be much appreciated.Below is the code i have come up with.Again i want to stress i am very new to C
#include<stdio.h>
#include<string.h>
int main()
{
char string[20];
char key[8];
char cout;
char random[20];
int i;
int j;
j=strlen(string);
printf("enter the cipher text");
scanf("%c",&string);
printf("enter the seed value");
scanf("%c",&key);
random[20]=srand(key);
for(i=0; i<=j; i++)
{
string[i]=string[i]^random[i];
cout=string;
}
printf("ciphertext is &s",cout);
}