Encryption compatibility

Hello,

I have a question regarding Encryption feature. Couchbase Lite uses SQLCipher, an open source extension to SQLite that provides transparent encryption (256-bit AES) of database files.

My sample steps would be,

  1. I have an application running without CBL Encryption enabled to users.
  2. Later I implement CBL DB Encryption by registering for Encryption key, and update new version of my App to users.
    What will happen in this scenario installing new app on top of older version app which did have DB but not encrypted?
    I want to know what happens for similar like compatibility scenarios?

You cannot open unencrypted databases using an encryption key and vice-versa. If an existing unencrypted db is present, then you will need to open it and use the change encryption key API.

If an existing DB was unencrypted, but to apply fresh encryption key to the existing unencrypted DB to convert as encrypted DB on the updated iOS app, Do I have to use ‘change encryption key’ API ? Won’t there be any data loss in the existing DB by doing these steps?

There will not be any data loss. You can convert databases at will. Just be informed that it is not a cheap operation and will take some time on large databases (though you probably won’t notice it until after 100 MB).