Sometimes it make sense to hide string value from binary (executable) file. For example, it really make sense to hide encryption key from executable file.
What I mean when I say "hide"?
Such code:
const char* encryptionKey = "My strong encryption key";
// Using the key
after compilation produce executable file with such section in data section:
4D 79 20 73 74 72 6F 6E-67 20 65 6E 63 72 79 70 |My strong encryp|
74 69 6F 6E 20 6B 65 79 |tion key |
This string can be easyly found and/or modified.
I can hide the string:
char encryptionKey[30];
int n = 0;
encryptionKey[n++] = 'M';
encryptionKey[n++] = 'y';
encryptionKey[n++] = ' ';
encryptionKey[n++] = 's';
encryptionKey[n++] = 't';
encryptionKey[n++] = 'r';
encryptionKey[n++] = 'o';
encryptionKey[n++] = 'n';
encryptionKey[n++] = 'g';
encryptionKey[n++] = ' ';
encryptionKey[n++] = 'e';
encryptionKey[n++] = 'n';
encryptionKey[n++] = 'c';
encryptionKey[n++] = 'r';
encryptionKey[n++] = 'y';
encryptionKey[n++] = 'p';
encryptionKey[n++] = 't';
encryptionKey[n++] = 'i';
encryptionKey[n++] = 'o';
encryptionKey[n++] = 'n';
encryptionKey[n++] = ' ';
encryptionKey[n++] = 'k';
encryptionKey[n++] = 'e';
encryptionKey[n++] = 'y';
// Using the key
But it's not nice method.
Any ideas?
PS: I know that it doesn't work against real hacker, but it's much beter than nothing...
Edit
I know about assymetric encryption, but it's not acceptable in this case.
I refactoring existing appication which uses Blowfish encryption.
Encrypted data passed to server and server decrypt data.
I can't change ecryption algorithm because I should provide backward compatibility.
I even can't change encryption key.