How To Encrypt Pre Existing Non Encrypted SQLite DB

I am using SQLCipher with .net Core . I want to encrypt non encrypted pre existing DB . What could be best way for that ? In Sample code , it looks it sends commands to empty DB file . For me the sample code says - ‘file is not a database’ for pre existing DB .

Is there any c#(.net core) commands to encrypt existing DB ?

Hi @Atul,

Thank you for your interest in SQLCipher. You can utilize the sqlcipher_export [1] convenience function to export a plaintext SQLite database to a encrypted database file. The SQL commands in example 1 of the linked documentation will be what you’re looking for. You’re going to open a connect to the plain text database file, then attach a non-existent database file specifying the password material during the attach. Running sqlcipher_export on the attached alias will populate the encrypted database with the schema and content from the plaintext database.


  1. SQLCipher API - Full Database Encryption PRAGMAs, Functions, and Settings | Zetetic ↩︎