【发布时间】:2018-09-16 21:27:20
【问题描述】:
我从here(wxSQLite3 3.5.9) 下载了预构建的二进制文件,还下载了sqlite3.h 文件版本3.21.0,我将头文件和.dll 和.lib 文件添加到我的项目中。
我复制了 32 位版本的 dll 和 lib 文件,并将它们复制到我的解决方案中,并将 .lib 文件添加到项目属性中 Linker->Input 中的 Additional Dependencies。
我用 C++ 创建了这个示例应用程序:
#define SQLITE_HAS_CODEC
#include "sqlite3.h"
#include <string>
#include <iostream>
using namespace std;
int main()
{
sqlite3* db;
sqlite3_open("test1.db", &db);
sqlite3_key(
db, /* Database to be rekeyed */
"test", sizeof("test") /* The key, and the length of the key in bytes */
);
std::string createQuery =
"CREATE TABLE IF NOT EXISTS items (userid INTEGER PRIMARY KEY, ipaddr TEXT, username TEXT, useradd TEXT, userphone INTEGER, age INTEGER, "
"time TEXT NOT NULL DEFAULT (NOW()));";
sqlite3_stmt* createStmt;
std::cout << "Creating Table Statement" << endl;
sqlite3_prepare(db, createQuery.c_str(), createQuery.size(), &createStmt, NULL);
cout << "Stepping Table Statement" << endl;
if (sqlite3_step(createStmt) != SQLITE_DONE) cout << "Didn't Create Table!" << endl;
string insertQuery =
"INSERT INTO items (time, ipaddr,username,useradd,userphone,age) VALUES('7:30', '192.187.27.55', 'vivekanand', 'kolkatta', '04456823948', 74);";
// WORKS!
sqlite3_stmt* insertStmt;
cout << "Creating Insert Statement" << endl;
sqlite3_prepare(db, insertQuery.c_str(), insertQuery.size(), &insertStmt, NULL);
cout << "Stepping Insert Statement" << endl;
if (sqlite3_step(insertStmt) != SQLITE_DONE) cout << "Didn't Insert Item!" << endl;
return 0;
}
但是如果我评论这部分代码
sqlite3_key(
db, /* Database to be rekeyed */
"test", sizeof("test") /* The key, and the length of the key in bytes */
);
它工作得很好,我做错了什么?
【问题讨论】:
-
您购买了 SQLite 的加密扩展吗?它不是免费产品,也不是主要 SQLite API 的一部分。
-
这里有一个开源实现github.com/utelle/wxsqlite3
-
我认为这只是 SQLite 扩展的包装器。这意味着您仍然应该为扩展本身付费。只需在 github 项目上询问 Ulrich 即可。就像 wxSQLite3 是 SQLite API 的包装器一样。
-
@Igor 这个存储库如何声称是开源的 sqlite 加密库? github.com/rindeal/SQLite3-Encryption 它使用了 wxSqlite 的一部分(基本上使编译更容易)
-
@Igor 在回购的描述中说
wxSQLite3 - SQLite3 database wrapper for wxWidgets (including SQLite3 encryption extension)
标签: c++ encryption sqlite wxwidgets dynamic-linking