Building SQLCipher on OS X
Published 2015-6-29Building
Using brew
Super simple:
brew options sqlcipher
brew install sqlcipher --with-fts
which sqlcipher
If you needed to change options manually you could edit /usr/local/Library/Formula/sqlcipher.rb
.
node.js sqlite3
export LDFLAGS="-L`brew --prefix`/opt/sqlcipher/lib"
export CPPFLAGS="-I`brew --prefix`/opt/sqlcipher/include"
npm install sqlite3 --build-from-source --sqlite_libname=sqlcipher --sqlite=`brew --prefix`
Using git
Still pretty straightforward.
# clone the repo
git clone https://github.com/sqlcipher/sqlcipher.git
pushd sqlcipher
# check if there are any interesting options
./configure --help
# CFLAGS will turn on encryption, default temp_store to memory,
# (file usage optional), enable full-text search, link to libcrypto
./configure CFLAGS="-DSQLITE_HAS_CODEC -DSQLITE_TEMP_STORE=2 -DSQLITE_ENABLE_FTS3 -lcrypto"
# just to be sure everything is in the initial state
make clean
# use as many CPUs as exist
# (you could also use 'sysctl -n hw.physicalcpu', which would not include 'logical' cores)
time make -j $(sysctl -n hw.ncpu)
It's a pretty quick compile
real 0m6.988s
user 0m5.786s
sys 0m1.537s
And finish up
sudo make install
which sqlcipher
node.js sqlite3
You'll probably need to use io.js. I definitely wouldn't expect this to work with node <= 0.12.
export LDFLAGS="-L/usr/local/lib"
export CPPFLAGS="-I/usr/local/include -I/usr/local/include/sqlcipher"
export CXXFLAGS="-I/usr/local/include -I/usr/local/include/sqlcipher"
npm install sqlite3 --build-from-source --sqlite_libname=sqlcipher --sqlite=/usr/local --verbose
Other
For instructions on RPi or Linux, see Building SQLCipher for RPi 2.
Testing
There are test files at Building SQLCipher for node.js for both standalone sqlcipher and the node sqlcipher.
By AJ ONeal
Thanks!
It's really motivating to know that people like you are benefiting
from what I'm doing and want more of it. :)
Did I make your day?
Buy me a coffee
(you can learn about the bigger picture I'm working towards on my patreon page )