赞
踩
编译和使用SQLite3MultipleCiphers
#include <cstdio>
#include "sqlite3.h"
#include "sqlite3mc.h"
#include "sqlite3mc_version.h"
#include "sqlite3mc_vfs.h"
#pragma comment(lib,"sqlite3mc_x64.lib")
int main() {
sqlite3* db;
sqlite3_open("test.db", &db);
sqlite3_key(db, "111111", 6);
sqlite3_exec(db, "create table person (id int, name vchar(50))", NULL, NULL, NULL);
int i = sqlite3_exec(db, "insert into person (id,name) values (234,'quit')", NULL, NULL, NULL);
printf("i=%d", i);
sqlite3_close(db);
}
运行该exe,就会生成一个加密的sqlite3数据库文件。
如果需要删除db文件的密码,先用sqlite3_key验证密码,再用函数sqlite3_rekey。
sqlite3_open("test.db", &db);
sqlite3_key(db, "111111", 6);
sqlite3_rekey(db, NULL, 0);
_WINDOWS WIN32 _CRT_SECURE_NO_WARNINGS _CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE CODEC_TYPE=CODEC_TYPE_CHACHA20 SQLITE_ENABLE_DEBUG=0 SQLITE_THREADSAFE=1 SQLITE_DQS=0 SQLITE_MAX_ATTACHED=10 SQLITE_ENABLE_EXPLAIN_COMMENTS=1 SQLITE_SOUNDEX=1 SQLITE_ENABLE_COLUMN_METADATA=1 SQLITE_SECURE_DELETE=1 SQLITE_ENABLE_DESERIALIZE=1 SQLITE_ENABLE_FTS3=1 SQLITE_ENABLE_FTS3_PARENTHESIS=1 SQLITE_ENABLE_FTS4=1 SQLITE_ENABLE_FTS5=1 SQLITE_ENABLE_RTREE=1 SQLITE_ENABLE_GEOPOLY=1 SQLITE_ENABLE_PREUPDATE_HOOK=1 SQLITE_ENABLE_SESSION=1 SQLITE_CORE=1 SQLITE_ENABLE_EXTFUNC=1 SQLITE_ENABLE_MATH_FUNCTIONS=1 SQLITE_ENABLE_CSV=1 SQLITE_ENABLE_VSV=1 SQLITE_ENABLE_CARRAY=1 SQLITE_ENABLE_UUID=1 SQLITE_TEMP_STORE=2 SQLITE_USE_URI=1 SQLITE_USER_AUTHENTICATION=1 SQLITE_ENABLE_DBPAGE_VTAB=1 SQLITE_ENABLE_DBSTAT_VTAB=1 SQLITE_ENABLE_STMTVTAB=1 SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION=1
设置完后,选择“debug”和“x64”即可成功。
#include <cstdio>
#include "sqlite3mc_amalgamation.h"
#pragma comment(lib,"sqlite163lib.lib")
int main() {
sqlite3* db;
sqlite3_open("test.db", &db);
sqlite3_key(db, "111111", 6);
sqlite3_exec(db, "create table person (id int, name vchar(50))", NULL, NULL, NULL);
int i = sqlite3_exec(db, "insert into person (id,name) values (22,'quit')", NULL, NULL, NULL);
printf("i=%d", i);
sqlite3_close(db);
}
选择“debug”和“x64”生成即可成功。
与方法2类似,只是采用SQLite3MultipleCiphers-1.6.3\src目录下的源代码,设置和编译过程一样。
调用的时候,采用如下:
#include "sqlite3.h"
#include "sqlite3mc.h"
#include "sqlite3mc_version.h"
#include "sqlite3mc_vfs.h"
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。