Sql Cipher database not getting encrypted in iOS and Swift language

Hi,
I integrated sqlcipher free Community Edition software in my application and implemented according to this sqlcipher tutorial in swift language for iOS application. I have checked my applications database after executing the code but data base is not getting encrypted(again checked in the way that was proposed in the tutorial).

Can you please help me in resolving this issue

Thanks,
Subbu

Hi @Subbu

Thank you for your interest in SQLCipher and for posting to the discussion forum. It sounds like your application may not be properly linking SQLCipher if the database isn’t encrypted.

I would recommend running this query: PRAGMA cipher_version; and see if the proper version is returned in the result.

How are you integrating SQLCipher (i.e. direct integration or CocoaPods)?

It would be helpful if you could link to a project on GitHub with your current configuration.

Cheers,
Micah

Hi,

I started integrating again and there was an error “use-of-unresolved-identifier-sqlite3-key”. can you please provide me some solution for this. I have tried all the following ways

  1. followed the instructions exactly as given in tutorial
  2. #define SQLITE_HAS_CODEC 1 is added in bridging file
  3. sqlite3.h and sqlite3.c are available (they are being fetched from sqlcipher successfully).
    I have been trying to find a solution for the error from past 3 days. can you please help me with this.

Thanks,
Subbu

@Subbu

I’ve just retried SQLCipher Community integration with Swift following the above linked tutorial (Xcode 9.4.1 and Xcode 10.0 beta 2) and both worked properly and encrypted the database (after inserting some data).

It’s hard to say exactly what is going wrong for you without seeing your project configuration. As mentioned in my previous reply, it would be helpful if you:

  1. Create a new project and performed the same integration as you’re doing currently.
  2. Upload it to GitHub.
  3. Link to it here and I could have a quick look.

Cheers,
Micah

Hi,

I tried doing it. it worked after deleting derived data. Can you provide me an example for encrypting and decrypting of database in swift language. As I couldn’t find any proper example to refer.
Thanks,
Subbu

@Subbu

Are you referring to encrypting an existing sqlite database and then creating a plaintext database from a SQLCipher database? If so then you’ll want to use sqlcipher_export() convenience function to accomplish the task. There are examples of the queries for each case in the link.

Cheers,
Micah