I have an important file saving in my app's document directory. I don't allow other to view its content so I encrypt the file with auto-generated AES key and encrypt this AES key with RSA public key, then save the encrypted AES key to NSUserDefaults.
When using the important file, I will fetch the encrypted AES key and decrypt the AES key with RSA public key, then decrypt the file.
But I don't know where to store the RSA private key, is it safe to write it in my code like NSString *rsaPrivateKey = @"%^^&*(())";
, if not, is there a safer solution ?
I know how to generate RSA public and private key using openssl (This link helps me)
Edit:
The important file is only open to the user himself, you can consider it as a photo with some sensitive content and the photo is saved by the user.