Is it possible to create a SQLite database in memory from an existing piece of memory?

From the documentation it seems like this is impossible, but I want to be sure. Here is my use case:

I want an encrypted database. It must be decrypted while it is in memory (while the program is running). The only way I can do this is to decrypt the file from disk before transferring it to SQLite. But I can’t find a way to give a SQLite pointer and say, "Here it is a database." I also cannot find a way to serialize the database in memory, and then encrypt it before writing to disk. I suggest that sqlite3_backup API will need an unencrypted database file?

I work on Android, so I would like to use the built-in SQLite, and I don’t think it would be possible to install SQLite Encryption Extension (SEE) . (Running on Android also means that I don't have full access to the C ++ API, but this time we can ignore it).

+4
source share
1 answer

Since you can replace the functions used by sqlite to interact with the file system from the application using the sqlite_vfs_register method, this should be possible. I have no experience with the encryption extension, but it is likely that it also uses this interface, so it could even be used.

+1
source

Source: https://habr.com/ru/post/1341812/


All Articles