sql.js
sql.js copied to clipboard
supporting some kind of encryption ? (perhaps sqlcipher?)
hi, i would like to be able to open encrypted sqlite db's with sql.js , how should i do it? do i have to decode integer array before passing it to sql.js or can you implant some kind of decryption methods internally ?
Hi, Currently, no sqlite encryption extension has been compiled to javascript. The simplest solution would be to decode the database before serving it to your clients.
The best solution would be to compile SQLite+sqlcipher to javascript with emscripten. If you start working on this, I'll help you, and integrate your work if you do a pull request. But I think this represents some work, and I don’t have time to do this all by myself now.
thanks for your time , but
decode the database before serving it to your clients
that pretty much defeats my purpose , i wanted my application to read encrypted version of database but only ones with specific keys (generated based on username in server-side) to prevent sharing of databases between users.
i'll try to find another way/library but if i didn't find a suitable alternative , i see what i can do to add sqlcipher to sql.js.
Could anyone shed some light on what would be involved in compiling sql.js with sqlcipher?
This is something I would really need in order to secure data on the client.
Thanks!
As sql.js stores the whole database in memory, I think there would be no significant performance penalty in deciphering the database in memory first, and then opening it with sql.js. The web crypto API is now widely supported
sqleet encryption extension works out-of-the-box with sql.js due to its standalone design (i.e., no OpenSSL dependencies or other crap). Simply compile sql.js after replacingc/sqlite3.c
and c/sqlite3.h
with sqleet.c
and sqleet.h
amalgamations from sqleet release package. Demo: https://huumeet.info/sqleet-js/
Thanks @resilar. I created a fork that includes sqleet instead of sqlite available here: https://github.com/pwnsdx/sqleet.js