Encrypting a Sqlite db file that will be bundled in a pyexe file

假装没事ソ 提交于 2020-01-11 06:26:09

问题


I have been working on developing this analytical tool to help interpret and analyze a database that is bundled within the package. It is very important for us to secure the database in a way that can only be accessed with our software. What is the best way of achieving it in Python?

I am aware that there may not be a definitive solution, but deterrence is what really matters here.

Thank you very much.


回答1:


This question comes up on the SQLite users mailing list about once a month.

No matter how much encryption etc you do, if the database is on the client machine then the key to decrypt will also be on the machine at some point. An attacker will be able to get that key since it is their machine.

A better way of looking at this is in terms of money - how much would a bad guy need to spend in order to get the data. This will generally be a few hundred dollars at most. And all it takes is any one person to get the key and they can then publish the database for everyone.

So either go for a web service as mentioned by Donal or just spend a few minutes obfuscating the database. For example if you use APSW then you can write a VFS in a few lines that XORs the database content so regular SQLite will not open it, nor will a file viewer show the normal SQLite header. (There is example code in APSW showing how to do this.)

Consequently anyone who does have the database content had to knowingly do so.




回答2:


Someone has gotten Python and SQLCipher working together by rebuilding SQLCipher as a DLL and replacing Python's sqlite3.dll here.



来源:https://stackoverflow.com/questions/3848658/encrypting-a-sqlite-db-file-that-will-be-bundled-in-a-pyexe-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!