c++ - 如何使用 C++ 在 sqlite3 中打开受密码保护的数据库?

标签 c++ sqlite

我正在尝试使用 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/

相关文章:

android - 应用程序打开的文件太多 - Android

c++ - 格式化 sqlite3_exec 结果

c++ - 预期 `;' 之前 "pennies"? C++调试(代码完成)

c++ - 无法追踪 Qt 程序崩溃的原因

c++ - Boost 的 Sublime Text 2 问题

c++ - PNACL——使用 winscard 库

c# - 创建 Windows Phone 8 应用程序并将其连接到数据库的最佳方式(最好是 SQL Server)

java - Android 上的特殊字符\n 和\r

sqlite - DATETIME 值如何在 SQLite 中工作?

c++ - 将小部件从一个选项卡复制到另一个选项卡时的 QTabWidget