I have encrypted database using “ATTACH DATABASE” and hex key. But while decrypting using same hex-key I am getting error “file is encrypted or is not a database”. is anything wrong while passing the pKey to sqlite3_key(). I am using sqlcipher-2.2.0 version. Please see the code below:
sqlite3_exec(persistence_db, "ATTACH DATABASE \'./encrypted.db\' AS db2 KEY \"x\'02\'\";", NULL, NULL, &zErrMsg);
sqlite3_exec(persistence_db, "SELECT sqlcipher_export('db2');", NULL, NULL, &zErrMsg);
sqlite3_exec(persistence_db,"DETACH DATABASE db2;",NULL, NULL, NULL)
//above 3 APIs returns SQLITE_OK
//but I got error while decrypting the same encrypted.db
sqlite3_key(persistence_db, "x'02'", 2);
sqlite3_exec(persistence_db, "SELECT count(*) FROM sqlite_master;", NULL, NULL, &zErrMsg);
//this returns with error: file is encrypted or is not a database