title: iOS: is it safe to hard-code AES key in my code?
body: <p>I have a project which require some data to be encrypted by AES. However, I hard code the AES key in my project like this:</p>
  
  <pre><code>NSString *passwd = @"someStringAsKey";
  NSData *encryptedData = [Encrypter encrypteData:unencryptedData];
  </code></pre>
  
  <p>If someone want to hack my binary to find the AES key I hard-coded, could it be easy? If it is, what's the better way to store AES key?</p>
  
  <p><strong>EDIT:</strong>
  The key is used to encrypt and decrypt a chunk of data,app download the data from server,and then app encrypt it and save the encrypted data on disk. 
  This key is used on a per-device basis, which means every device could have it own key as long as every time app runs, it knows how to generate the key.</p>
  
  <p><strong>EDIT2:</strong>
  The data downloading procedure is protected by this way: the client generate a random private/public key pair every time it login. It send the public key to server, and server use public key to encrypt an AES key, then send encrypted AES key to client. Client decrypt the AES key and put it in memory. Then client and server transport data encrypted by that AES key.</p>
  
  <p>I'm aimed to protect the data on disk to not decrypted by hacker. I assume that what hacker can get is my binary image and data on disk. Also hacker can run my app on his own device and analyze memory.</p>
  
  <p>I don't need to protect this kind of attack: the hacker is so smart that he wrote a virus runs on jailbroken devices and the virus can analyze my app's running memory to search for some key in memory. So we don't need to worry about the safety of network transporting.</p>