sqlcipher 简介
SQLCipher是一个对sqlite数据库进行aes256加密的开源库,提供透明,安全的256位AES加密的SQLite数据库文件,项目本身不提供加密算法,调用openssl的aes加密算法
SQLCipher的社区版的源代码是一个BSD-风格的开源许可下发布,但是官方提供的二进制库需要购买。
官网链接:http://sqlcipher.net
下载链接:https://github.com/sqlcipher/sqlcipher
移植
SQLCipher依赖openssl库,需先安装openssl;(移植方法可参见:OpenSSL 移植)
解压:
1 unzip sqlcipher-master.zip
2 cd sqlcipher-master/
①Ubuntu上移植安装:
1.1配置
./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC -I/usr/local/ssl/include/" LDFLAGS="-lcrypto" --prefix=$PWD/pc_install
1.2安装
1 make
2 make install
②arm-linux 交叉编译:
2.1配置
./configure --host=arm-linux --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC -L/home/work/lib/openssl-1.0.1f/arm_share_install/lib/" LDFLAGS="-lcrypto" --prefix=$PWD/arm_install CC=/usr/local/arm/crosschain/am335x/bin/arm-arago-linux-gnueabi-gcc
2.2安装
1 make
2 make install
测试
C代码测试:
编写测试代码test.c:
#include <stdio.h>
#include <stdlib.h>
#include <sqlite3.h>(整理上传...)
Ubuntu上测试:
编译:
gcc -g test.c -o test -lsqlcipher -L /home/work/lib/sqlcipher-master/pc_install/lib/ -I /home/work/lib/sqlcipher-master/pc_install/include/sqlcipher/
拷贝运行时所依赖的库:
cp /home/work/lib/sqlcipher-master/pc_install/lib/libsqlcipher.so* /usr/lib/
运行:
./test
搞定!
arm-linux上测试:
编译:
/usr/local/arm/crosschain/am335x/bin/arm-arago-linux-gnueabi-gcc -g test.c -o test -lsqlcipher -L /home/work/lib/sqlcipher-arm/arm_install/lib/ -I /home/work/lib/sqlcipher-arm/arm_install/include/sqlcipher/
拷贝运行时所依赖的库:
cp /home/work/lib/sqlcipher-arm/arm_install/lib/libsqlcipher.so* /usr/lib/ (usr/lib为开发板上路径,openssl相关库也需在开发板上)
运行:
./test
搞定!