sqlcipher 移植

sqlcipher 簡介

  SQLCipher是一個對sqlite數據庫進行aes256加密的開源庫,提供透明,安全的256位AES加密的SQLite數據庫文件,項目自己不提供加密算法,調用openssl的aes加密算法
  SQLCipher的社區版的源代碼是一個BSD-風格的開源許可下發布,可是官方提供的二進制庫須要購買。linux

  官網連接:http://sqlcipher.netgit

  下載連接:https://github.com/sqlcipher/sqlciphergithub

移植

  SQLCipher依賴openssl庫,需先安裝openssl;(移植方法可參見:OpenSSL 移植)算法

解壓:sql

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配置spa

./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 搞定!
相關文章
相關標籤/搜索