How to store a secret API key in an application's binary?

后端 未结 4 470
青春惊慌失措
青春惊慌失措 2020-12-02 22:34

I am creating a Twitter client for Mac OS X and I have a Consumer secret. It\'s to my understanding I should not share this secret key. The problem is that

4条回答
  •  执笔经年
    2020-12-02 23:19

    You could just base64-encode it to obfuscate it. Or, better idea, generate the key instead of just storing it - write something like this:

    char key[100];
    ++key[0]; ... ; ++key[0]; // increment as many times as necessary to get the ascii code of the first character
    // ... and so on, you get the idea.
    

    However, a really good hacker will find it no matter what; the only way to really protect it from others' eyes is using a secure hash function, but then you won't be able to retrieve it, too :)

提交回复
热议问题