views:

149

answers:

2

I have a string in my code that I use as a secret when I communicate with my server. What is the best way to encypt this string to ensure that a hacker will not be able to find it out by searching my binary or looking into the memory during run time? (if possible to prevent at all?)

What are some measures you would suggest to at least make this as diffcult as possible?

+1  A: 

Technically it's not possible, one can always at least memory scrape the code just after decryption before the connect, and as the whole decryption algorithm needed is also already available in the code. A disassembly will allow one decrypt the data straight from the binary.

In practise as this is a closed platform (from the fact you used the iphone tag), it'll only be major hackers that would manage to get it even if it's just a plain hexadecimal string in the binary.

ewanm89
What are some measures you would suggest to at least make this as diffcult as possible?
erotsppa
Just put the string in place - it will be meaningless to someone scanning for strings. Then always use HTTPS in communicating with your server so it can't be snooped. Of course, then you have to pay the performance penalty for using HTTPS but it's the only way to keep it even kind of secret.
Kendall Helmstetter Gelner
Well, why exactly do you need this string, is it to try to make it so only your binary connects to your server?
ewanm89
+2  A: 

A far better approach would be to monitor use from your server and try to detect usage patterns that did not match your application - such as knowing it would always make one kind of request before another, or that an iPhone ID you pass up as a parameter to a call was not used excessively from multiple sources. You could have it make an initial call when the app first starts and record on the server the phone ID to allow other calls.

There are multiple ways to approach the problem, but they are all server based - anything in the client can and will be seen by a hacker. Anything the client says must always be treated as a lie, for sometimes it will be.

Kendall Helmstetter Gelner
adobe haven't even learnt this yet ;)
ewanm89