how do i encrypt things that are say 10 characters long with a key that is 5. like this
char string[10];
char key[5];
string=string^key;
only encrypts half of string.
Printable View
how do i encrypt things that are say 10 characters long with a key that is 5. like this
char string[10];
char key[5];
string=string^key;
only encrypts half of string.
Go through each character and XOR it with the string and uh... use the key over again for all leftover sets of characters of string...?
I don't know, that's a pretty simple encryption...
Use the key twice. Or extend the key.
>string=string^key;
Isn't this going wrong? The variables string and key are addresses. For encryption you need a loop and xor each character.
Code:#define KLEN 10
#defien VLEN 200
char val[2002];
char key[322];
char *pv = val;
char *pk = key;
while(*pv) {
*pv ^= *pk;
if(*pk)
pk++;
else
pk = key;
pv++;
}