一、下载代码:
sqlcipher依赖openssl库,首先下载openssl:
[[email protected] ~]$ git clone https://github.com/openssl/openssl.git
下载sqlcipher:
站点:http://git.oschina.net/fulinux/sqlcipher.git或者https://github.com/sqlcipher/sqlcipher.git
[[email protected] ~]$ git clone http://git.oschina.net/fulinux/sqlcipher.git或者
[[email protected] ~]$ git clone https://github.com/sqlcipher/sqlcipher.git
二、编译:
编译openssl:
[[email protected] openssl]$ ./config
[[email protected] openssl]$ sudo make install编译sqlcipher:
[[email protected] sqlcipher]$./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="-lcrypto"
如果遇到编译问题,请checkout到发行版本
[[email protected] sqlcipher]$git checkout v3.1.0
[[email protected] sqlcipher]$ ls sqlciphersqlcipher
三、测试:
新建一个数据库:
[[email protected] sqlcipher]$ ./sqlcipher test.dbSQLCipher version 3.8.4.3 2014-04-03 16:53:12Enter ".help" for instructionsEnter SQL statements terminated with a ";"sqlite> PRAGMA KEY = '12345';sqlite> create table film (number,name);sqlite> insert into film values (1,'aaa');sqlite> insert into film values (2,'bbb');sqlite> select * from film;1|aaa2|bbbsqlite> .quit打开上面创建的数据库:
[[email protected] sqlcipher]$ ./sqlcipher test.dbSQLCipher version 3.8.4.3 2014-04-03 16:53:12Enter ".help" for instructionsEnter SQL statements terminated with a ";"sqlite> PRAGMA KEY = '12345';sqlite> .schemaCREATE TABLE film (number,name);sqlite> select * from film;1|aaa2|bbbsqlite>
错误测试:
[[email protected] sqlcipher]$ ./sqlcipher test.dbSQLCipher version 3.8.4.3 2014-04-03 16:53:12Enter ".help" for instructionsEnter SQL statements terminated with a ";"sqlite> select * from film;Error: file is encrypted or is not a databasesqlite>
author: fulinux
e-mail:[email protected]
blog: blog.csdn.net/fulinus