Best way to save data securely on iOS?

I talk in detail about small (with the exception of 1 KB) data.
For example, I have game statistics (high scores and all other statistics, the game won, ...), and I need to save it, but I do not want this user to be able to edit (crack) this data.

This is the workflow that I still have:
(there will be some kind of code, because I believe that the code best explains)

  • I am creating an object GameStatistic, i.e. singleton.
  • When I call the save method on it, it does the following:
    • NSData* encodedData = [NSKeyedArchiver archivedDataWithRootObject: self]
    • [encodedData writeToFile:[GTN_GameStatistics filePath] atomically:YES];
    • NSString* checksum = [KeychainWrapper computeSHA256DigestForData: encodedData];
    • and then I save checksumtoKeyChain

So basically I use the checksum SHA256stored in KeyChain, as a decision against messing with the bills.

Is there any way to improve it?

I have never used Core Data, but I know that it has some kind of encryption.
Is encoding better than Core Data, or is my current solution better?

UPDATE
NSUserDefault cannot respond.
NSUserDefault is basically a plist file in Library / Preferences.
Therefore, anyone can change it, for example, the user can use iFunBox and change everything.

I am familiar with NSUserDefault, and I only use it for data that I don’t like if the user changes the form outside of my application.
 As for setting the sound of the game incl. Or off

+4

Source: https://habr.com/ru/post/1544137/


All Articles