Written by
HK
At
Tue Oct 29 2024
To use sqlite with encryption enabled, rusqlite is a popular option. Just enable bundled-sqlcipher
feature.
It's super simple on Mac and Linux, on Windows, I have to configure OpenSSL library, it's a bit harder than Linux/Mac.
First download openssl from https://slproweb.com/products/Win32OpenSSL.html
OpenSSL is a very important library used everywhere. This website looks a bit old and I don't know if I can trust it. Why don't Microsoft include it in Windows or provide an official way to install it?
Download the latest, larger file, not the light installer.
The file I downloaded was Win64OpenSSL-3_4_0.msi
, install it.
Before installing, here is the error
OPENSSL_DIR
is missing.
My install path is C:\Program Files\OpenSSL-Win64
.
Set OPENSSL_DIR
to C:\Program Files\OpenSSL-Win64
.
Then remove target
and build again. This time I get new errors
libcrypto.lib
is not found.
For my installation, I found the file under C:\Program Files\OpenSSL-Win64\lib\VC\x64\MDd
I need to add environment variable OPENSSL_LIB_DIR
to C:\Program Files\OpenSSL-Win64\lib\VC\x64\MDd
Then it works. DB is encrypted. VSCode has sqlite viewer extension. Try open the encrypted db file, it won't open as it's encrypted.
From instructions online, I initially set OPENSSL_LIB_DIR
to C:\Program Files\OpenSSL-Win64\lib
, it doesn't work.
You may also want to set OPENSSL_INCLUDE_DIR
to C:\Program Files\OpenSSL-Win64\include\
Also, you have to restart code editor everytime PATH is changed.
As a Mac user and Linux fan, Windows is too hard for developers. Even deleting files could be a big problem as it's used by some process. I rarely had these problems on Mac and Linux.
Also configuring environment variables on Mac and Linux is simply editing files.
How is this guide?