Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone: How to encrypt a string

I would like to encrypt a string with AES 256 on the iPhone but have not found much via google. What I am trying to do is post some data to a web site as part of a game I am creating, but I do not want the user to be able to cheat by seeing how it is posted because it is plain text. So I want to post one encrypted string to my php page (ala www.test.com/test.php?encrypted= etc...) and then the php script will decrypt it and do what it needs to if it is valid.

like image 355
Codezy Avatar asked Jan 23 '23 08:01

Codezy


2 Answers

You can just use the CryptoHelper which is adopted by CyrptoExercise Sample Project

like image 168
notnoop Avatar answered Jan 25 '23 22:01

notnoop


A much easier approach here would be to use an HTTPS POST, which would give you similar protections with far less code, though there are still difficulties for solving the problem you're attacking. The kind of solution you're describing generally requires some kind of shared secret, and it's very hard to protect code using a shared secret for long. You may find these posts helpful:

  • Machine ID for Mac
  • Store an encryption key in Keychain while application installation process
  • Obfuscating Cocoa

Still, HTTPS is probably a much better solution than AES here.

like image 30
Rob Napier Avatar answered Jan 25 '23 23:01

Rob Napier