Thank you. Is there any other way to define the 'received encrypted output' from transmitter as a char? Because my RC4 encryption function is defined as char and if I change as above to int the error shows as
- invalid conversion from 'int' to 'char*'
- error: initializing argument 2 of 'void rc4(char*, char*)'.
I am new in this environment with limited knowledge of programming. Your answer will be highly appreciated. RC4 function code:
unsigned char S[256];
char has[512];
#define S_SWAP(a,b) do { int t = S[a]; S[a] = S[b]; S[b] = t; } while(0)
void rc4(char *key, char *data){
int i,j;
for (i=0;i<256;i++){
S[i] = i;
}
j = 0;
for (i=0;i<256;i++){
j = (j+S[i]+key[i%strlen(key)]) %256;
S_SWAP(S[i],S[j]);
}
i = j = 0;
for (int k=0;k<strlen(data);k++){
i = (i+1) %256;
j = (j+S[i]) %256;
S_SWAP(S[i],S[j]);
has[k] = data[k]^S[(S[i]+S[j]) %256];
}
has[strlen(data)+1] = '\0';
}
Thanks in advance for the comment.