stephencelis / SQLite.swift

A type-safe, Swift-language layer over SQLite3.
MIT License
9.57k stars 1.55k forks source link

Encrypt Plain text Db (expose sqlcipher_export) #1101

Closed mahsha closed 1 year ago

mahsha commented 2 years ago

I Hope you expose these functions in sqlite swift API to encrypt plain text DB

try dbConnection.execute("ATTACH DATABASE '\(encryptedPath)' AS encrypted KEY '\(password)';")
try dbConnection.execute("SELECT sqlcipher_export('encrypted');")
try dbConnection.execute("DETACH DATABASE encrypted;")
jberkel commented 2 years ago

Yes, this is planned. See #1098

jberkel commented 1 year ago

Will get released in 0.14.0

liyuan116 commented 1 year ago

hi @jberkel When will 0.14.0 be released ?

jberkel commented 1 year ago

@liyuan116 I resumed working on the project, it should be some point this week

liyuan116 commented 1 year ago

[Decrypt a SQLCipher database to a Plaintext Database](https://www.zetetic.net/sqlcipher/sqlcipher-api/#example-2-I Hope you expose these functions in sqlite swift API decrypt-a-sqlcipher-database-to-a-plaintext-database) public func plaintextexport( location: Location, key: String) throws { let schemaName = "plaintext" let sql = "PRAGMA key = (key)" try run(sql) try attach(location, as: schemaName, key: "") try run("SELECT sqlcipher_export(?)", schemaName) try detach(schemaName) } @jberkel