0

Is it possible to open an existing SQLite database with SQLCipher?

Until now, I was managed only to create a new database using SQLCipher in order to work with it.

Thanks!

Tomer Rubin
  • 173
  • 2
  • 17

1 Answers1

1

Yes, you can open an existing SQLite database, go through the documentation : http://sqlcipher.net/ios-tutorial/

Sharon Nathaniel
  • 1,467
  • 20
  • 28
  • Hi Sharon, can you explain the steps to me? say I have an existing database which is unencrypted. then what? – Tomer Rubin Jun 13 '13 at 09:56
  • To encrypt a database programatically you can use the sqlite3_key function. The data provided in pKey is converted to an encryption key according to the same rules as PRAGMA key. int sqlite3_key(sqlite3 *db, const void *pKey, int nKey); PRAGMA key or sqlite3_key should be called as the first operation when a database is open. – Sharon Nathaniel Jun 13 '13 at 10:02
  • 3
    To encrypt a plaintext database, you will want to use the sqlcipher_export function, specifically look at example 1: http://sqlcipher.net/sqlcipher-api/#sqlcipher_export – Nick Parker Jun 13 '13 at 15:20