# How To Encrypt Pre Existing Non Encrypted SQLite DB

**URL:** https://discuss.zetetic.net/t/how-to-encrypt-pre-existing-non-encrypted-sqlite-db/6868
**Category:** SQLCipher
**Created:** [March 13, 2025, 11:30am UTC](https://discuss.zetetic.net/t/how-to-encrypt-pre-existing-non-encrypted-sqlite-db/6868 "2025-03-13T11:30:08Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Atul](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@Atul](https://discuss.zetetic.net/u/Atul)
#### Post date: [March 13, 2025, 11:30am UTC](https://discuss.zetetic.net/t/how-to-encrypt-pre-existing-non-encrypted-sqlite-db/6868/1 "2025-03-13T11:30:09Z")

</div>

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 ?

---

<div class="post-metadata">

### Author: ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)
#### Post date: [March 13, 2025, 1:47pm UTC](https://discuss.zetetic.net/t/how-to-encrypt-pre-existing-non-encrypted-sqlite-db/6868/2 "2025-03-13T13:47:47Z")

</div>

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](https://www.zetetic.net/sqlcipher/sqlcipher-api/#sqlcipher_export)
