sql.js icon indicating copy to clipboard operation
sql.js copied to clipboard

supporting some kind of encryption ? (perhaps sqlcipher?)

Open zumoshi opened this issue 10 years ago • 6 comments

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 ?

zumoshi avatar Jul 03 '14 07:07 zumoshi

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.

lovasoa avatar Jul 03 '14 10:07 lovasoa

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.

zumoshi avatar Jul 04 '14 01:07 zumoshi

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!

sebastianmacias avatar Feb 20 '18 05:02 sebastianmacias

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

lovasoa avatar Feb 24 '18 10:02 lovasoa

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/

resilar avatar Apr 08 '19 07:04 resilar

Thanks @resilar. I created a fork that includes sqleet instead of sqlite available here: https://github.com/pwnsdx/sqleet.js

ghost avatar May 23 '19 12:05 ghost