How do you open an encrypted SQLITE db on the iPhone?

10,796

To create a new encrypted SQLite database or to open an existing encrypted SQLite database you have to call the function sqlite3_key or to execute a "pragma key=" command immediately after opening the database before performing any other database operation.

I suspect that you tried to open an existing, but not encrypted SQLite database and expected to encrypt it by using one of the above methods. This doesn't work but results in the error message you experienced.

To encrypt an existing not encrypted SQLite database you have to use function sqlite3_rekey or "pragma rekey=" command.

To change the encryption key of an existing encrypted SQLite database you have to open the database, then to use sqlite3_key (or "pragma key=") and then to apply sqlite3_rekey (or "pragma rekey=").

Share:
10,796
Lewion
Author by

Lewion

Updated on June 04, 2022

Comments