# How to custom encrypt algorithm in sqlcipher

**URL:** <https://discuss.zetetic.net/t/how-to-custom-encrypt-algorithm-in-sqlcipher/5951>\
**Category:** SQLCipher\
**Created:** [May 30, 2023, 9:45am UTC](https://discuss.zetetic.net/t/how-to-custom-encrypt-algorithm-in-sqlcipher/5951 "2023-05-30T09:45:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gomez](https://avatars.discourse-cdn.com/v4/letter/g/d78d45/32.png) [@gomez](https://discuss.zetetic.net/u/gomez)\
**Post date:** [May 30, 2023, 9:45am UTC](https://discuss.zetetic.net/t/how-to-custom-encrypt-algorithm-in-sqlcipher/5951/1 "2023-05-30T09:45:18Z")

</div>

We used wxsqlite3 to encrypt database, using the algorithm AES 128 Bit CBC - No HMAC. We want to migrate to sqlcipher but the existing database is encrypted using AES 128 Bit CBC - No HMAC. May I ask:

1. Is there a way to seamlessly migrate databases?
2. Does sqlcipher have an interface for custom encryption algorithms?

---

<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 30, 2023, 12:36pm UTC](https://discuss.zetetic.net/t/how-to-custom-encrypt-algorithm-in-sqlcipher/5951/2 "2023-05-30T12:36:56Z")

</div>

Hello @gomez - there is not currently a seamless way to migrate from wxsqlite3 to SQLCipher. The underlying implantations are different, even outside of the algorithms that are used. You would likely need to write a special program which would decrypt the existing database, after which you could re-encrypt it using SQLCipher. This would all be custom code.

In terms of custom encryption, you can build a custom SQLCipher cryptographic provider to implement custom encryption features. There are example providers included with the community source, including ones for OpenSSL, Common Crypto, etc. I would note that we strongly recommend against using custom / non-standard encryption algorithms without a very good reason, as it impacts security and compatibility.

In summary, migration and custom encryption would both be possible, but would require fairly complicated customization. I will finally mention that under the SQLCipher Enterprise program we do provide customization and development services for extending SQLCipher. If you’d be interested in talking to us about building a solution to meet your needs, please contact us at [support@zetetic.net](mailto:support@zetetic.net).

---

<div class="post-metadata">

**Author:** ![utelle](https://avatars.discourse-cdn.com/v4/letter/u/ee7513/32.png) [@utelle](https://discuss.zetetic.net/u/utelle)\
**Post date:** [March 14, 2024, 8:02am UTC](https://discuss.zetetic.net/t/how-to-custom-encrypt-algorithm-in-sqlcipher/5951/3 "2024-03-14T08:02:40Z")

</div>

> [@gomez](#):
>
> Is there a way to seamlessly migrate databases?

Yes, there is. The project [SQLite3 Multiple Ciphers](https://github.com/utelle/SQLite3MultipleCiphers) (on which wxSQLite3 is based) supports to change the cipher scheme of a database with a few simple pragma statements:

```auto
PRAGMA cipher=sqlcipher; -- select SQLCipher encryption scheme
PRAGMA legacy=4; -- select SQLCipher version
PRAGMA rekey='your passphrase'; -- rekey database

```
