Mercurial > prosody-hg
diff util/sqlite3.lua @ 13632:844e7bf7b48a
util.sql: SQLCipher support
This enables use of encrypted databases if LuaDBI or LuaSQLite3 has been
linked against SQLCipher. Using `LD_PRELOAD` may work as well.
Requires SQLCipher >= 4.0.0 due to the use of UPSERT
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Thu, 23 Jan 2025 16:38:56 +0100 |
| parents | f2578a69ccf4 |
| children | e7c52d0b0e0d |
line wrap: on
line diff
--- a/util/sqlite3.lua Tue Jan 21 17:21:48 2025 +0100 +++ b/util/sqlite3.lua Thu Jan 23 16:38:56 2025 +0100 @@ -114,6 +114,12 @@ if not dbh then return nil, err; end self.conn = dbh; self.prepared = {}; + if params.password then + local ok, err = self:execute(("PRAGMA key='%s'"):format((params.password:gsub("'", "''")))); + if not ok then + return ok, err; + end + end local ok, err = self:set_encoding(); if not ok then return ok, err;
