Thanks for all your help, i might not explaining the problem that i’m facing correctly :
the database (sqlite file) is already exist, and it is an encrypted database.
and i have the key for the database, and according to your post here
The same process also works in reverse to create a plaintext, fully decrypted, copy of an encrypted SQLCipher database that can be opened with standard SQLite.
$ ./sqlcipher encrypted.db
sqlite> PRAGMA key = 'testkey';
sqlite> ATTACH DATABASE 'plaintext.db' AS plaintext KEY ''; -- empty key will disable encryption
sqlite> SELECT sqlcipher_export('plaintext');
sqlite> DETACH DATABASE plaintext;
I implement the same:
after int rc = sqlite3_open()
rc = sqlite3_exec(db, "PRAGMA key=\"x'theKeyForDB'\";", NULL, NULL, &errMsg);
rc = sqlite3_exec(db, "ATTACH DATABASE 'plaintext.sqlite' AS plaintext KEY '';", NULL, NULL, &errMsg);
rc = sqlite3_exec(db, "SELECT sqlcipher_export('plaintext');", NULL, NULL, &errMsg);
rc = sqlite3_exec(db, "DETACH DATABASE plaintext;", NULL, NULL, &errMsg);
And this is the error messages that i got after each sqlite3_exec():
attach error: file is not a database
export funciton error: no such function: sqlcipher_export
cant perform query: file is not a database
The database that i want to decrypt is signal application database in ios, using the CLS for sqlcipher works perfect.