SQLite 数据库加密的一种解决方案
sqlite3 *db; sqlite3_stmt *stat; char *zErrMsg = 0; char temp[256],FileRoot[256]; char buffer2[1024]="0";
sprintf(temp,_T("%s"),_T("utf.db")); CCodingConv::GB2312_2_UTF8(FileRoot,256,temp,0); sqlite3_open(FileRoot,&db);
if (db == NULL) { return -1; }
sqlite3_key(db,"1q2w3e4r",8);
sqlite3_exec(db,"CREATE TABLE list (fliename varchar(128) UNIQUE,fzip text);",&zErrMsg); sqlite3_prepare(db,"insert into list values (' 中文GB2312 编码',?);",-1,&stat,0);
strcpy(temp," 测试数据UTF-8 的支持情况"); int len = (int )strlen(temp);
sqlite3_bind_text(stat,1,len,NULL); sqlite3_step(stat);
sqlite3_prepare(db,"select * from list;",0); sqlite3_step(stat);
const unsigned char * test = sqlite3_column_text(stat,1); int size = sqlite3_column_bytes(stat,1);
printf("%s",test);
sqlite3_finalize(stat); //sqlite3_rekey(db,"",0); sqlite3_close(db); (vc2003)http://www.sqlite.com.cn/Upfiles/source/sqlite3crypt.rar (vs2005)http://www.sqlite.com.cn/Upfiles/source/sqlite3_3_7_key.rar (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |