Use SQLCipher/Encryption on a prepopulated SQLite database

时间:2017-10-30 15:33:32

标签: android database sqlite encryption sqlcipher

I've been searching a way to implement SQLCipher on my prepopulated database containing more than a million entries. Last three months is the time I've fully devoted to my project's database and it's now complete which led me to a problem.

My app's database is something that I know will be copied in a week or so and copying database is so easy (just open the apk with WinRAR). And in India, No one cares about copyrights so that'll be of no use.

Basically I want to protect my app's database from copying keeping in mind that app should work offline (that being said no PHP/SQL servers).

I've checked GitHub/Google for it and only thing I've found is SQLCipher by Zetetic. Very same thing on GitHub - Here.

Also, One can import following library now: net.zetetic:android-database-sqlcipher:3.5.2@aar and can use this for securing database but it's something works on databases created by app and not on prepopulated. (lib taken from this answer on SO).

-> Now, for me the million dollar question is Is there anyway by which I can either password protect or encrypt my database without putting the database on any server?

P.S. -> I want to make my app work offline and also, I'm just a student and at least for now, can't afford Zetetic's paid service.

Edit - I've gone through codes of some google apps storing databases for some help but they are just using .out files (easily openable with Word/Text editor) compressed in .gz files which is not something I should use.

1 个答案:

答案 0 :(得分:3)

  

在我的预填充数据库上实施SQLCipher

这毫无意义。任何想要获取加密数据库,从您的应用程序中获取加密密钥并解密数据库的人。

  

我想保护我的应用数据库不被复制

请勿将其放在设备上。

  

请记住应用应该离线工作

根据应用程序的性质,您可以缓存一些数据以供离线使用,以便在离线时减少功能。

更简单的解决方案是不要担心数据库可能被复制的事实。用Tim O'Reilly的话说,你的问题不是安全,而是默默无闻。