赞
踩
SqlCipher的编译
编译前,先安装openssl和tcl.
TCC = $(TCC) -DSQLITE_ENABLE_FTS4
RCC = $(RCC) -DSQLITE_ENABLE_FTS4
TCC = $(TCC) -DSQLITE_ENABLE_JSON1
RCC = $(RCC) -DSQLITE_ENABLE_JSON1
TCC = $(TCC) -DSQLITE_ENABLE_FTS3
RCC = $(RCC) -DSQLITE_ENABLE_FTS3
TCC = $(TCC) -DSQLITE_ENABLE_FTS3_PARENTHESIS
RCC = $(RCC) -DSQLITE_ENABLE_FTS3_PARENTHESIS
TCC = $(TCC) -DSQLITE_ENABLE_FTS5
RCC = $(RCC) -DSQLITE_ENABLE_FTS5
TCC = $(TCC) -DNOCRYPT
RCC = $(RCC) -DNOCRYPT
TCC = $(TCC) -DSQLCIPHER_CRYPTO_OPENSSL
RCC = $(RCC) -DSQLCIPHER_CRYPTO_OPENSSL
方法1:
A)先把数据导出:
$ sqlite3 ifood.sqlite
>.output ifood.sql
>.dump
B)创建一个新的加密的数据库:
$ sqlcipher ifood_lock.sqlite
sqlite> PRAGMA key = ‘112233’; # 设置密码
C)导入数据
>.read ifood.sql
方法2:
A)创建数据库:
sqlcipher-shell64.exe encrypted .db
PRAGMA key = 'password';
create table encrypted (id integer, name text);
.schema
CREATE TABLE encrypted (id integer, name text);
B)对已有数据库进行加密:
sqlcipher-shell64.exe universal.db
ATTACH DATABASE 'encrypted.db' AS encrypted KEY 'password';
SELECT sqlcipher_export('encrypted');
DETACH DATABASE encrypted;
C)修改密码:
sqlite> PRAGMA rekey = 'newPassword’;
D)打开加密的数据库:
sqlcipher-shell64.exe encrypted .db
PRAGMA key = 'password’;
.schema
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。