Could anyone post code sample of how to open sqlcipher database? I guess that we need to call the key function in some way.
Asked
Active
Viewed 2,986 times
2 Answers
2
Assuming you've installed SQLite.swift with SQLCipher support (if not, follow these instructions), you merely need to call the key
function on your Database
object:
import SQLite
let db = Database("path/to/ciphered.sqlite3")
db.key("your_key")
Once keyed, you can change the encryption key using rekey
:
db.rekey("your_new_key")

leolobato
- 2,359
- 3
- 32
- 51

stephencelis
- 4,954
- 2
- 29
- 22
-
The instructions are to include SQLCipher on your Podfile: `pod 'SQLite.swift/SQLCipher'` – leolobato May 16 '18 at 11:25
1
Take a look at SQLite.swift.
- To see how to call the underlying sqlcipher functions. e.g.
sqlite3_key()
, see Cipher.swift - To see how to open a sqlcipher database in SQlite.swift with a key: CipherTests.swift

mhawke
- 84,695
- 9
- 117
- 138