coleifer / pysqlite3

SQLite3 DB-API 2.0 driver from Python 3, packaged separately, with improvements
zlib License
183 stars 51 forks source link

Adding encryption support #70

Closed alyxv-dev closed 7 months ago

alyxv-dev commented 7 months ago

Hello, I am wondering if you are interested implementing this as a feature. I tried to add the sqlite3_key_v2() function to the connection.c file + editing the PyArg_ParseTupleAndKeywords plus the variables for a password as a simple string but I am running into a segfault. I also tried to change sqlite3_open_v2() to sqlite3_open() because I was unsure the schema argument for sqlite3_key_v2() but it ended with them same segfault. Since I am not that experienced with python module programming, maybe I missed something that is required. SQLite3MultipleCiphers works on a simple test c file for me without this segfault.

Maybe you have the time, the will and the same opinion that this would be a nice feature to implement.

Thanks in advance.

EDIT: By the way the build went well and the segfault is:

Program received signal SIGSEGV, Segmentation fault.
sqlite3mcCodecSetup (passwordLength=8, userPassword=0x7ffff3312360 "password", cipherType=0, codec=0xb5f3d8)
    at ../src/cipher_common.c:249
249       codec->m_hmacCheck = sqlite3mcGetCipherParameter(globalParams, "hmac_check");
coleifer commented 7 months ago

No plans for adding this, but for those interested you can use the sqlcipher3 project -- this project provides the same driver code as pysqlite3 (this repo) but instead links against libsqlcipher3. The keys can easily be managed via pragma statements and an additional API is not needed.

coleifer commented 7 months ago

Eh, why not here they are: 513803c230a2821a2369910944a7aa0750fa3d8a