我正在尝试使用 c++ 中的 sqlite3 以编程方式打开受密码保护的数据库。
sqlite3 *m_sqlite; int ret = sqlite3_open("test.db", &m_sqlite);
但它用于打开普通数据库,还有其他功能可以打开受密码保护的数据库。
最佳答案
您可以使用sqlite3_user_authenticate
打开需要身份验证的数据库。
语法如下。
int sqlite3_user_authenticate(
sqlite3 *db, /* The database connection */
const char *zUsername, /* Username */
const char *aPW, /* Password or credentials */
int nPW /* Number of bytes in aPW[] */
);
调用顺序如下。
int ret = sqlite3_open("test.db", &m_sqlite);
ret = sqlite3_user_authenticate(m_sqlite,"username","password",8);
有关更多信息,请参阅 https://www.sqlite.org/src/doc/trunk/ext/userauth/user-auth.txt sqlite 文档。
关于c++ - 如何使用 C++ 在 sqlite3 中打开受密码保护的数据库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52418891/