How to protect data integrity for this case?

I tried to save some important data into files.

For example, when the user purchases coins via IAP, I will write the coin amount into a file.

I already have encrypted these files I am using with a key, so they cannot be edited.

However, how to resolve this case?

(1) The user purchases some coins via IAP.

(2) The app writes the amount of coins into a file, abc.dat

(3) The user copies abc.dat out

(4) The user uses all coins

(5) The user copies the original abc.dat back so the user now has the previous amount of coins

Is there any other way to store this kind of data so that the user cannot cheat the system?

Thanks.

There is a wonderful module called GGDatathat might be useful to you.

I wrote a little about it here: http://roaminggamer.com/2014/06/15/secure-data-storage-for-corona-sdk/

Question: How rampant do you think this practice will be?  

I suggest weighing effort vs. perceived loss.  I have had many products*  stolen and abused by pirates so I know your frustration.  However, at some point (after basic efforts to protect yourself) you may have to draw a line on effort.

Just a thought.

* I spent 5 years after my 40 hour a week job at Intel, writing these two books and within weeks of publishing the hardcopies, someone had scanned them into ‘free PDFs’.  @##@$%! :frowning:

The GGData integrity check can prevent the user edit the file.

But in the case I point out, what if the user copies the files out & copies back later?

PS. I can understand if it’s worthy to do such things. But I am just thinking if there is some “industry standard” method I am missing & I like to learn.

There is a wonderful module called GGDatathat might be useful to you.

I wrote a little about it here: http://roaminggamer.com/2014/06/15/secure-data-storage-for-corona-sdk/

Question: How rampant do you think this practice will be?  

I suggest weighing effort vs. perceived loss.  I have had many products*  stolen and abused by pirates so I know your frustration.  However, at some point (after basic efforts to protect yourself) you may have to draw a line on effort.

Just a thought.

* I spent 5 years after my 40 hour a week job at Intel, writing these two books and within weeks of publishing the hardcopies, someone had scanned them into ‘free PDFs’.  @##@$%! :frowning:

The GGData integrity check can prevent the user edit the file.

But in the case I point out, what if the user copies the files out & copies back later?

PS. I can understand if it’s worthy to do such things. But I am just thinking if there is some “industry standard” method I am missing & I like to learn.