[pyar] ¿Existe una base de datos embebida protegida por contraseña, usable en python?
Pedro Ignacio Guridi
pedro.guridi en gmail.com
Mie Feb 4 10:17:49 ART 2015
Hola,
Yo uso sqlite cifrado hace tiempo, lo que hice fue compilar esa
sqlitecipher que comenta ralsina, te da como resultado un archivo
sqlite3.dll igual que la original (pero con cifrado claro), y luego
compilo una version modificada de APSW [1] que este linkeada a la
sqlite3.dll hecha com sqlitecipher para agregar el parametro del
password en el metodo connect.
Parches para apsw 3.7.4-r1:
--- apsw-3.7.4-r1/setup.py 2010-12-12 22:54:14.000000000 -0300
+++ /home/pguridi/workspace/apsw/setup.py 2014-12-16 22:54:57.169041538 -0300
@@ -21,7 +21,8 @@
include_dirs=['src']
library_dirs=[]
define_macros=[]
-libraries=[]
+#libraries=["libeay32", "user32", "advapi32", "Gdi32"]
+libraries=["ssl"]
# This includes the functionality marked as experimental in SQLite 3.
# Comment out the line to exclude them
--- apsw-3.7.4-r1/src/connection.c 2010-12-12 22:54:14.000000000 -0300
+++ /home/pguridi/workspace/apsw/src/connection.c 2014-12-16
22:46:45.792469996 -0300
@@ -380,9 +380,10 @@
int flags=SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
char *vfs=0;
int statementcachesize=100;
+ PyObject* password;
sqlite3_vfs *vfsused=0;
- if(!PyArg_ParseTupleAndKeywords(args, kwds,
"es|izi:Connection(filename,
flags=SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, vfs=None,
statementcachesize=100)", kwlist, STRENCODING, &filename, &flags,
&vfs, &statementcachesize))
+ if(!PyArg_ParseTupleAndKeywords(args, kwds,
"esO|izi:Connection(filename, password,
flags=SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, vfs=None,
statementcachesize=100)", kwlist, STRENCODING, &filename, &password,
&flags, &vfs, &statementcachesize))
return -1;
if(statementcachesize<0)
@@ -392,9 +393,12 @@
could be registered between our find and the open starting.
Don't do that! We also have to manage the error message thread
safety manually as self->db is null on entry. */
+
PYSQLITE_VOID_CALL(
- vfsused=sqlite3_vfs_find(vfs); res=sqlite3_open_v2(filename,
&self->db, flags, vfs); if(res!=SQLITE_OK)
apsw_set_errmsg(sqlite3_errmsg(self->db));
+ vfsused=sqlite3_vfs_find(vfs); res=sqlite3_open_v2(filename,
&self->db, flags, vfs);
+ if(res!=SQLITE_OK) apsw_set_errmsg(sqlite3_errmsg(self->db));
);
+ sqlite3_key(self->db, PyString_AsString(password),
(int)strlen(PyString_AsString(password)));
SET_EXC(res, self->db); /* nb sqlite3_open always allocates the db
even on error */
if(res!=SQLITE_OK)
slds,
Pedro
[1] https://github.com/rogerbinns/apsw
2015-02-03 21:19 GMT-03:00 Marian <mavignau en gmail.com>:
> sqlite tiene el inconveniente de que no permite ser protegida x contraseñas
>
> Gracias
>
> _______________________________________________
> pyar mailing list pyar en python.org.ar
> http://listas.python.org.ar/listinfo/pyar
>
> PyAr - Python Argentina - Sitio web: http://www.python.org.ar/
>
> La lista de PyAr esta Hosteada en USLA - Usuarios de Software Libre de
> Argentina - http://www.usla.org.ar
More information about the pyar
mailing list