If I have an integer like this in several places in my code…
int my_secret = 42;
… is it possible to make it more difficult to find that integer in the compiled program? I’ve seen this done with strings, for example by shifting each letter by x characters and then un-shifting them at runtime, but I doubt this technique would work well with numbers.
You can do this by splitting this value between two variables. For instance like this:
and then use my_secret_1 + my_secret_2 instead of my_secret.
The volatile keyword is needed because most of (if not all) the c compilers would optimize it otherwise. In any way it is better to see what assembler code is produced by a compiler.