Encrypting or password protecting SQLite file

Creating desktop or client-server database solutions?

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
booee
Posts: 7
Joined: Fri Mar 27, 2015 9:48 pm

Encrypting or password protecting SQLite file

Post by booee » Mon Nov 18, 2019 9:15 pm

I'm creating an iOS game, and create a SQLite database file to save data taking place in the game.

I have read that someone with decent knowledge could essentially access and open up that file, and make edits to it.
Is there anyway to prevent a user from doing there? Either by encrypting or password protecting the SQLite file itself?

Thanks for any ideas!

bwmilby
Posts: 280
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: Encrypting or password protecting SQLite file

Post by bwmilby » Tue Nov 19, 2019 12:51 am

My guess is that encrypting the file would not work well due to how SQLite works. You certainly could store your data inside the database encrypted though. Depending on how much data you are dealing with, you could use other file formats that could be more easily encrypted directly (LSON as one example).
Brian Milby

Script Tracker https://github.com/bwmilby/scriptTracker

mrcoollion
Posts: 417
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: Encrypting or password protecting SQLite file

Post by mrcoollion » Tue Nov 19, 2019 9:19 am

Hi booee,

I have a total different solution when I need to store data for an application but do not need to share the data.
I Have two global arrays in any application I build.
  • 1 for keeping data that I want to save in a protected ini file
  • 1 for all data I need while the app is running
I only have to keep track of the data in the global arrays and for the ini file save all data when something changes through one simple procedure and read the data during start of the application into the global array.

Here is an example stack (hope I did not make any mistakes, tested it only twice!).
DemoSaveAppData.zip
Demo Save App Data to ini file encrypted
(1.73 KiB) Downloaded 11 times
Regards,

Paul

booee
Posts: 7
Joined: Fri Mar 27, 2015 9:48 pm

Re: Encrypting or password protecting SQLite file

Post by booee » Tue Dec 03, 2019 4:41 pm

That is super clever, Mr Coolion.
I ended up doing a very crude encryption process, by just creating encoding and decoding upon save and load.
Your process is much more clever, and I'll probably swing back around and implement something like this instead. Thank you so much for sharing!

mrcoollion
Posts: 417
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: Encrypting or password protecting SQLite file

Post by mrcoollion » Tue Dec 03, 2019 5:31 pm

My pleasure,
:D

Post Reply

Return to “Databases”