You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had encountered a bug with the c version code when I had tried to decrypt the encrypted string.
void encryptDecrypt(char *input, char *output) {
char key[] = {'K', 'C', 'Q'}; //Can be any chars, and any size array
int i;
for(i = 0; i < strlen(input); i++) {
output[i] = input[i] ^ key[i % (sizeof(key)/sizeof(char))];
}
}
There is a bug when do the encryption and decryption in one function above.
As the strlen(input) may be smaller than the original string length.So is the below:
void encryptDecrypt(char *input, char *output, int size) {
char key[] = {'K', 'C', 'Q'}; //Can be any chars, and any size array
int i;
for(i = 0; i < size; i++) {
output[i] = input[i] ^ key[i % (sizeof(key)/sizeof(char))];
}
}
The text was updated successfully, but these errors were encountered:
I had encountered a bug with the c version code when I had tried to decrypt the encrypted string.
There is a bug when do the encryption and decryption in one function above.
As the strlen(input) may be smaller than the original string length.So is the below:
The text was updated successfully, but these errors were encountered: