Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to check if DB is encrypted #910

Open
casperson opened this issue Apr 16, 2019 · 3 comments
Open

How to check if DB is encrypted #910

casperson opened this issue Apr 16, 2019 · 3 comments

Comments

@casperson
Copy link

As shown in this file below, db.rekey() will either change the key or it will encrypt a database with the key if it was not encrypted previously. Is there a way for me to check if the DB is encrypted before I call db.rekey()? I only want to run db.rekey() if the db isn't encrypted, just so it will get encrypted, but then in future cases, I will only want to use db.key() to access database. No need to change the key. It looks like there is an internal function called cipher_key_check() that checks that, any way to expose this somehow to make it an easy check?

public func rekey(_ key: String, db: String = "main") throws {

@casperson
Copy link
Author

As another comment, I tested rekey() on an open, unencrypted database, and it didn't encrypt that database? Either I did something wrong, or that is not the correct functionality. In the original documentation for SQLCipher it doesn't do that.

@SolorzanoJose
Copy link

For me, I have to call rekey twice for the sql file to get encrypted, is anyone else experiencing this

@jberkel
Copy link
Collaborator

jberkel commented Aug 24, 2021

can you not just try to open it without setting a key?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants