Best way to securely ship static text inside a iOS

2019-04-16 02:05发布

问题:

I got this app where I have numerous predefined strings displayed to the user. However, I want to protect them from being copied as a whole from my .ipa. Seems that I can't use PLists, XMLs and so on to store them since they are easily readable for snoops. Any idea how to effectively obscure them?

回答1:

Use any encryption you want and decrypt strings on runtime? Still readable if i.e. someone finds the key, but makes it a bit more problematic.



回答2:

Encrypt them with AES using Rob Napier's RNCryptor library.

He explains how in his blog entry here: Properly encrypting with AES with CommonCrypto:

NSData *iv;
NSData *salt;
NSError *error;
NSData *encryptedData = [RNCryptManager encryptedDataForData:plaintextData
                                                    password:password
                                                          iv:&iv
                                                        salt:&salt
                                                       error:&error];

Rob's advanced iOS books look very promising. I'm no relation, honest.

The key thing is you can't store the encryption key on the device. Instead, consider using the user's password as the key. Users often choose poor passwords, so first pass it through a hash function.

When the user logs in, run the password through the same hash function and decrypt the data.