# Pragma Cipher not persisting on IOS

**URL:** <https://discuss.zetetic.net/t/pragma-cipher-not-persisting-on-ios/2381>\
**Category:** Issues\
**Created:** [September 26, 2017, 7:09pm UTC](https://discuss.zetetic.net/t/pragma-cipher-not-persisting-on-ios/2381 "2017-09-26T19:09:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisfahlin](https://avatars.discourse-cdn.com/v4/letter/c/e274bd/32.png) [@chrisfahlin](https://discuss.zetetic.net/u/chrisfahlin)\
**Post date:** [September 26, 2017, 7:09pm UTC](https://discuss.zetetic.net/t/pragma-cipher-not-persisting-on-ios/2381/1 "2017-09-26T19:09:51Z")

</div>

I am trying to set the cipher version on my IOS apps to use GCM encryption by running the command `PRAGMA cipher = 'aes-256-gcm'` What I’m finding is on all of my apps, IOS is not persisting this cipher change and defaulting back to CBC mode.

Has anyone ran into this issue of the cipher mode not persisting, or is it even possible on IOS to change the cipher?

_Edit_ I forgot to mention, I am running this command right after I set the key, and this issue is showing up on older Objective C projects as well as a newer swift project

---

<div class="post-metadata">

**Author:** ![mmoore](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/mmoore/32/858_2.png) [@mmoore](https://discuss.zetetic.net/u/mmoore)\
**Post date:** [September 26, 2017, 8:39pm UTC](https://discuss.zetetic.net/t/pragma-cipher-not-persisting-on-ios/2381/2 "2017-09-26T20:39:22Z")

</div>

Hi @chrisfahlin

If you’re using the default cipher provider for iOS (common crypto) you’re not going to be able to change the cipher at runtime as it doesn’t support multiple ciphers.

As noted on the [SQLCipher design page](https://www.zetetic.net/sqlcipher/design/) under “Security Features”:

> The default algorithm is 256-bit AES in CBC mode (cipher and mode can be changed at run time via PRAGMA cipher, though only when using a cryptography provider that supports multiple ciphers, i.e. OpenSSL).

You can check your cipher provider by running `PRAGMA cipher_provider`

If you build SQLCipher for iOS using OpenSSL as a crypto provider it should support changing ciphers.

> **[SQLCipher Community Edition - iOS and macOS Tutorial](https://www.zetetic.net/sqlcipher/ios-tutorial/)**
>
> How to use SQLCipher Community Edition in iOS and macOS projects

[https://www.zetetic.net/blog/2013/6/27/sqlcipher-220-release.html](https://www.zetetic.net/blog/2013/6/27/sqlcipher-220-release.html)

I’d also like to note that `PRAGMA cipher` is deprecated, and should be removed in future implementations.

Please let me know if you have any further questions. Thanks!

Cheers,  
Micah
