Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving game score locally on iOS device...is security needed?

Do I need to store the score with a hash, ie to protect it from being edited/cheated by a user? From my newb knowledge, the user is unable to view and manipulate this locally stored data, as plist files for example. Can anyone elaborate?

[Edit] I'm storing scores locally and periodically uploading them to Game Center leaderboards. Even if the device is jailbroken I'd like to have security to prevent scores being manipulated by the user. What is a good approach?

like image 609
andrewz Avatar asked Jul 01 '11 05:07

andrewz


1 Answers

I actually would do this:

Save it in an NSDictionary and convert it to an NSData object. Now comes the cool part:

Encrypt it into AES using this class:
https://web.archive.org/web/20160806074714/http://iphonedevelopment.blogspot.com/2009/02/strong-encryption-for-cocoa-cocoa-touch.html

This is a military standard encryption which will return an encrypted NSData object. Then just save it to file and read/write whenever necessary. I've had really good experiences with this class and the user can't do anything to it.

Much better than just storing it in plain sight using NSUserDefaults.

Give it a go!

like image 187
Pripyat Avatar answered Oct 05 '22 02:10

Pripyat