I found the following XOR encryption function on the internet:
void xor_encrypt(char *key, char *string)
{
int i, string_length = strlen(string);
for(i=0; i<string_length; i++)
{
string[i]=string[i]^key[i];
printf("%i", string[i]);
}
}
It works perfect, but I would like to decrypt the string also.
For example:
void xor_decrypt(char *key, char *encrypted_string)
{
//decrypt method goes here
}
So basically after I encrypt the string, I would use the same encryption key to decrypt the previously encrypted string.
I'm pretty new to programming and I would just like to know how to decrypt the previously encrypted string. Thanks, all help is appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…