1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

When compiling with SQLITE_HAS_CODEC, honor the hexkey= query parameter on

URI pathnames in sqlite3_open_v2().

FossilOrigin-Name: e0ce3fc089c2523b8b718b4a4f9ab8c4d0432fc7
This commit is contained in:
drh
2015-10-26 14:41:35 +00:00
parent 56d90be183
commit 46e6ea0282
3 changed files with 22 additions and 7 deletions

View File

@@ -2954,6 +2954,21 @@ opendb_out:
void *pArg = sqlite3GlobalConfig.pSqllogArg;
sqlite3GlobalConfig.xSqllog(pArg, db, zFilename, 0);
}
#endif
#if defined(SQLITE_HAS_CODEC)
if( rc==SQLITE_OK ){
const char *zHexKey = sqlite3_uri_parameter(zOpen, "hexkey");
if( zHexKey && zHexKey[0] ){
u8 iByte;
int i;
char zKey[40];
for(i=0, iByte=0; i<sizeof(zKey)*2 && sqlite3Isxdigit(zHexKey[i]); i++){
iByte = (iByte<<4) + sqlite3HexToInt(zHexKey[i]);
if( (i&1)!=0 ) zKey[i/2] = iByte;
}
sqlite3_key_v2(db, 0, zKey, i/2);
}
}
#endif
return rc & 0xff;
}