I am currently developing an application in Delphi, in which I have to hide (obfuscate) a string in source code like str := 'Example String'.
Why ? Because if I open the EXE in text editor and search for Example String I’ll find the string in second…
I tried to use a basic HEX transcription like #$65#$78#$61#$6d#$70#$6c#$65 but it’s re-transcribed in clear at compile time.
I looked for packers, but it’s not the best solution (PECompact can be detected as a false positive malware, UPX is too easy to de-UPX, …). I would prefer an idea in my internal code…
Someone would put me on the right way.
A very simple method is to store the strings obfuscated by the ROT13 method.
Slightly more sophisticated would be to employ the Caesar chipher or the Vigenère chipher.
To obtain the obfuscated strings to use in the source code, you can use a decent text editor like my own Rejbrand Text Editor or Wolfram|Alpha.
Update
ROT13 is very easy to decipher, but it might be more than enough for your situation, depending on how it looks! At least it will become very hard to identify strings in the binary. It will take some real effort to obtain the strings. (After all, the every-day user don’t even look at binaries in a hex editor/text editor!) The Caesar cipher is a very simple generalisation of the ROT13 cipher, and is also easily deciphered. Indeed, there are only 25 different ‘passwords’. The Vigenère cipher is far trickier, and takes some really serious effort to crack (especially since you don’t know precisely where in the binary the strings are).
As an example, below I give a string obfuscated using the Vigenère cihper:
It would certainly be possible to extend the cipher to also take care of digits and special characters, including spaces. It could also be made to mix capitals and small letters. Then it would be terribly hard (although possible) to decipher. It is probably far easier to decipher if the password is a known word, which can be found in the dictionary. If it is not a word, it will be safer.
The text above is obfuscated using a word that you can find in a large-enough dictionary. The text below is obfuscated using a nonsense string as password:
And, finally, the text below is obfuscated the same way, but – in addition – all spaces and special characters have been removed from the string:
I challenge you to decipher these three texts. If anyone would succeed in deciphering the last one, I promise to give this person 100 SEK (100 Swedish kronor)!
But, still, Warren P is right: If you really require high security, that even the experts will not be able to decipher, then you should go for some real encryption.
Update
As requested by Warren P, I use the following code to encrypt/decrypt Vigenère: