读书人

sqlite 数据库的加密有关问题。

发布时间: 2013-01-11 11:57:35 作者: rapoo

sqlite 数据库的加密问题。。
sqlite 数据库的加密有关问题。


知道免费的sqlite是不带加密的,只提供了sqlite_key();这个空函数,没有实现定义,所以上面的才会报错的。。

-----------------------------
论坛里有谁遇到这样的问题,是怎么解决的,看了网上的wxsqlite是是实现了sqlite的加密,但是那个c++封装的,而且自己也没看明白,自己因为是做嵌入式的,所以想问一下,论坛里有没有哪位高人做过这个的。
[解决办法]
就用wxsqlite的sqlite 里面有个sqlite文件夹里有源码 用的时候还得在sqlite3.h里面加上宏定义 什么什么CODEC的 忘记了 这样就可以把key函数声明出来
[解决办法]

引用:
引用:就用wxsqlite的sqlite 里面有个sqlite文件夹里有源码 用的时候还得在sqlite3.h里面加上宏定义 什么什么CODEC的 忘记了 这样就可以把key函数声明出来


我这个是没定义,老大,undefined

我看到源码里有sqlite_key()这个函数,只是他没有定义是个空函数,,


undefined是没定义吧 你看看头文件啊 这个函数的前后被一个ifdef之类的围住了 假如没定义的话 提示是未解析的外部符号
你下载的是官方的版本么? 官方的是没实现 而且头文件不给这个接口的
你可以去混合wxsqlite的加密文件放进去 然后修改头文件就能用了
[解决办法]

#ifdef SQLITE_HAS_CODEC
/*
** Specify the key for an encrypted database. This routine should be
** called right after sqlite3_open().
**
** The code to implement this API is not available in the public release
** of SQLite.
*/
SQLITE_API int sqlite3_key(
sqlite3 *db, /* Database to be rekeyed */
const void *pKey, int nKey /* The key */
);

/*
** Change the key on an open database. If the current database is not
** encrypted, this routine will encrypt it. If pNew==0 or nNew==0, the
** database is decrypted.
**
** The code to implement this API is not available in the public release
** of SQLite.
*/
SQLITE_API int sqlite3_rekey(
sqlite3 *db, /* Database to be rekeyed */
const void *pKey, int nKey /* The new key */
);

/*
** Specify the activation key for a SEE database. Unless
** activated, none of the SEE routines will work.
*/
SQLITE_API void sqlite3_activate_see(
const char *zPassPhrase /* Activation phrase */
);
#endif

#ifdef SQLITE_ENABLE_CEROD
/*
** Specify the activation key for a CEROD database. Unless
** activated, none of the CEROD routines will work.
*/
SQLITE_API void sqlite3_activate_cerod(
const char *zPassPhrase /* Activation phrase */
);
#endif


官方的头文件是这样的 假如要使用 要定义一个


#ifndef SQLITE_HAS_CODEC
#define SQLITE_HAS_CODEC
#endif

然后把wxsqlite的加密文件拿过来一起编译就行了
不然用的时候就会提示未定义的符号 sqlite3_key

读书人网 >其他数据库

热点推荐