Like everyone else, you cannot measure the API key and use it in your application. However, you can make simple obfuscation relatively easy, and if the crackerβs winnings are low, you may not burn out.
One easy way is to split your API key into multiple substrings. Make sure you put them in your code in some random order. For example, if your API key is 12345678901234567890, you can break it into 5 substrings, for example:
static char *part1 = "12345"; static char *part5 = "7890"; static char *part3 = "890123"; static char *part2 = "67"; static char *part4 = "456";
If you run /usr/bin/strings in the resulting binary, you should not see the API key in order. Instead, you will see API substrings in the order specified in your C file. With 5 substrings like this, this is 5 * 4 * 3 * 2 * 1 = 120 permutations. If you divide it into 13 substrings, you will see more than 6 billion permutations.
However, this does not stop anyone who knows what they are doing from getting your API key if he wants to. In the end, you will have to combine the lines together and pass them to one of your methods, after which the cracker can use the debugger to set a breakpoint and check the memory.
source share