# Migrate plain text DB to encrypted DB in C#

**URL:** <https://discuss.zetetic.net/t/migrate-plain-text-db-to-encrypted-db-in-c/4412>\
**Category:** SQLCipher\
**Created:** [May 21, 2020, 4:42pm UTC](https://discuss.zetetic.net/t/migrate-plain-text-db-to-encrypted-db-in-c/4412 "2020-05-21T16:42:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![snatarajan](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@snatarajan](https://discuss.zetetic.net/u/snatarajan)\
**Post date:** [May 21, 2020, 4:42pm UTC](https://discuss.zetetic.net/t/migrate-plain-text-db-to-encrypted-db-in-c/4412/1 "2020-05-21T16:42:54Z")

</div>

Is there a sample code to use the sqlcipher\_export functionality in Xamarin shared project with C# code?

---

<div class="post-metadata">

**Author:** ![sjlombardo](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/sjlombardo/32/3_2.png) [@sjlombardo](https://discuss.zetetic.net/u/sjlombardo)\
**Post date:** [May 21, 2020, 5:31pm UTC](https://discuss.zetetic.net/t/migrate-plain-text-db-to-encrypted-db-in-c/4412/2 "2020-05-21T17:31:28Z")

</div>

Hello @snatarajan - if you are using official Zetetic Commercial or Enterprise packages you can contact us at [support@zetetic.net](mailto:support@zetetic.net).

---

<div class="post-metadata">

**Author:** ![snatarajan](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@snatarajan](https://discuss.zetetic.net/u/snatarajan)\
**Post date:** [May 21, 2020, 5:36pm UTC](https://discuss.zetetic.net/t/migrate-plain-text-db-to-encrypted-db-in-c/4412/3 "2020-05-21T17:36:55Z")

</div>

Hi,  
We are currently using Community Edition of SQLCipher in our Xamarin project. I am using the following libraries in my projects:  
Xamarin.Android:  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/zetetic/original/2X/e/ef4bd46b27ec7b7e2aed17d4cb49d1dc08e76ace.png)  
Xamarin.iOS  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/zetetic/original/2X/5/56d6ecd156ecef63c226231a12bf9866c0e98c62.png)  
Xamarin.Shared:  
sqlite-net-sqlcipher

I ahve implemented encyption for new users. But would like to know how we migrate existing users through sqlcipher\_export functionality in Xamarin C# world.

---

<div class="post-metadata">

**Author:** ![sjlombardo](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/sjlombardo/32/3_2.png) [@sjlombardo](https://discuss.zetetic.net/u/sjlombardo)\
**Post date:** [May 21, 2020, 7:07pm UTC](https://discuss.zetetic.net/t/migrate-plain-text-db-to-encrypted-db-in-c/4412/4 "2020-05-21T19:07:02Z")

</div>

Hello @snatarajan we don’t provide direct support for 3rd party .NET packages like you are using. However, you can find general purpose documentation for how to use sqlcipher\_export here: [https://www.zetetic.net/sqlcipher/sqlcipher-api/#sqlcipher\_export](https://www.zetetic.net/sqlcipher/sqlcipher-api/#sqlcipher_export)

---

<div class="post-metadata">

**Author:** ![snatarajan](https://avatars.discourse-cdn.com/v4/letter/s/0ea827/32.png) [@snatarajan](https://discuss.zetetic.net/u/snatarajan)\
**Post date:** [May 21, 2020, 8:32pm UTC](https://discuss.zetetic.net/t/migrate-plain-text-db-to-encrypted-db-in-c/4412/5 "2020-05-21T20:32:02Z")

</div>

OK thankyou. Can you please tell me for the sqlcipher\_export function in the 3rd line

$ ./sqlcipher plaintext.db  
sqlite\> ATTACH DATABASE ‘encrypted.db’ AS encrypted KEY ‘newkey’;  
sqlite\> SELECT sqlcipher\_export(‘encrypted’); – **is this the variable(encrypted) name or the encrypted.db name?**  
sqlite\> DETACH DATABASE encrypted;

---

<div class="post-metadata">

**Author:** ![sjlombardo](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/sjlombardo/32/3_2.png) [@sjlombardo](https://discuss.zetetic.net/u/sjlombardo)\
**Post date:** [May 22, 2020, 3:15pm UTC](https://discuss.zetetic.net/t/migrate-plain-text-db-to-encrypted-db-in-c/4412/6 "2020-05-22T15:15:54Z")

</div>

Hello @snatarajan that is the logical name that you used for the attached database in the first step.
