简体   繁体   English

在 Python 中使用 SQLCipher - 最简单的方法

[英]Using SQLCipher in Python - the easy way

I'm coding a Python utility that should work on an encrypted SQLite database.我正在编写一个 Python 实用程序,它应该适用于加密的 SQLite 数据库。 Eventually I'll turn such utility into a executable, so it'll be easier to ship to the rest of my team.最终,我会将此类实用程序转换为可执行文件,以便更轻松地发送到我团队的 rest。 I read many pages about SQLCipher but they all talk about compiling stuff and installing in Windows - really, I have a hard time at fully understand that, it seems like they take some steps for granted and I get lost.我读了很多关于 SQLCipher 的页面,但他们都在谈论编译东西并在 Windows 中安装 - 真的,我很难完全理解这一点,似乎他们采取了一些理所当然的步骤,我迷路了。

Where can I find a detailed, step-by-step guide that allows me to have Python code that works properly on an encrypted SQLite database, with no system dependencies, and then such code is compilable into an exe (with pyinstaller)?我在哪里可以找到详细的分步指南,让我拥有 Python 代码,该代码可以在加密的 SQLite 数据库上正常工作,没有系统依赖性,然后这些代码可以编译成 exe(使用 pyinstaller)? Even having an exe and a dll would be fine.即使有一个 exe 和一个 dll 也可以。

Thanks for your help.谢谢你的帮助。

PS: I think that the exe + dll is a viable option because DB Browser for SQLite ( https://github.com/sqlitebrowser/sqlitebrowser ) ships with that very dll. PS: I think that the exe + dll is a viable option because DB Browser for SQLite ( https://github.com/sqlitebrowser/sqlitebrowser ) ships with that very dll. Maybe it's re-usable?也许它可以重复使用?

I was able to copy the ssleay32.dll, libeay32.dll, and sqlcipher.dll in to the Python38\DLLs folder.我能够将 ssleay32.dll、libeay32.dll 和 sqlcipher.dll 复制到 Python38\DLLs 文件夹中I then renamed sqlite3.dll to sqlite3.dll.old.然后我将 sqlite3.dll 重命名为 sqlite3.dll.old。 sqlcipher.dll needs to be renamed to sqlite3.dll. sqlcipher.dll 需要重命名为 sqlite3.dll。 Then call it like you would for sqlite.然后像 sqlite 一样调用它。

For Linux对于 Linux

sudo apt update
sudo apt upgrade
sudo apt install python3-pip python3-dev build-essential libssl-dev libffi-dev python3-setuptools
sudo apt-get install libsqlcipher-dev
sudo apt install build-essential git cmake libsqlite3-dev
sudo apt install sqlcipher
git clone https://github.com/rigglemania/pysqlcipher3
cd pysqlcipher3
python3 setup.py build
sudo python3 setup.py install

if installing in virtual environment also do
pip install pysqlcipher3 in the environment

if sys.platform.lower() == 'linux':
  try:
     from pysqlcipher3 import dbapi2 as sqlite3
  except:
     import sqlite3

you can use pysqlitecipher module - https://github.com/harshnative/pysqlitecipher你可以使用pysqlitecipher模块 - https://github.com/harshnative/pysqlitecipher

You will loose the built in sqlite features but you can implement them directly in python such as queries etc. it handles encryption in the background so you don't have to worry, also the encryption standard is great too.您将失去内置的 sqlite 功能,但您可以直接在 python 中实现它们,例如查询等。它在后台处理加密,因此您不必担心,加密标准也很棒。

problem solved by above module - Their is not a easy solution to encrypted sqlite database using python.上述模块解决的问题 -他们不是使用 python 加密 sqlite 数据库的简单解决方案。

All the solutions available difficult to set up and if you do get, then converting the solution to executable is even more difficult.所有可用的解决方案都很难设置,如果你得到了,那么将解决方案转换为可执行文件就更加困难了。

But pysqlitecipher i build on core python, so it is easily convertable to exe using modules such as pyinstaller但是 pysqlitecipher 我建立在核心 python 上,因此可以使用 pyinstaller 等模块轻松将其转换为 exe

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 有没有在Python中使用二进制数的简单方法? - Is there an easy way of using binary numbers in Python? 有没有一种简单的方法可以在 Python 中编写这个? - Is there an easy way to write this in Python? 有没有一种简单的方法可以使用 python 将图像转换为二维码? - Is there an easy way to convert an image to QR code using python? 有没有一种简单的方法可以使用 Python 从 NCBI 下载 fasta 格式的基因组? - Is there an easy way to download genomes in fasta format from NCBI using Python? 有什么简单的方法可以在gae上使用python获取完整的url - has any easy way to get full url using python on gae 使用Python解析.h文件以便评论的简单方法? - Easy way to parse .h file for comments using Python? 有没有一种简单的方法可以使用本机python在OSX上发送SCSI passthrough - Is there an easy way to send SCSI passthrough on OSX using native python 如何使用 Python 以简单的方式检查非线性关系? - How to check in easy way non-linear relationships using Python? 有没有一种简单的方法可以使用 Python 从 html 页面中提取文档树? - Is there an easy way to pull the document tree from an html page using Python? 使用 Python OpenCV 裁剪部分图像的简单方法是什么 - What is the easy way to crop a part of image using Python OpenCV
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM