Transparent Compression Support

Hi, Is it possible to add transparent compression support to Sqlcipher? You know, after encrypting a database it became uncompressible. One of your developers said this to me:
"You could potentially use something like zlib before/after encryption/decryption"
Please clarify and explain how I can do this. I have built Sqlcipher from source code, so I am a bit familiar with the code. Thanks for your efforts.

1 Like

Hello @ray_pixar,

Something like this would need to hook the codec API, which SQLCipher is already using extensively. It would probably need to do something very special for compressed databases, along the lines of pre-processing to compress, encrypt and pack the data. This would result in a read only database, since it wouldn’t be feasible to allow rewrites of pages because depending on the content, the size of the data could change (e.g. consider a case where some content contained a series of strings all with the same character, which would be highly compressed, and then it was updated to contain random data, which would not be as compressible).

We can’t really provide any more specific guidance on how to do this. I suspect that it would not be a trivial implementation. That said, I should also mention that Zetetic does provide commercial customization services for SQLCipher, and this is something we could potentially explore. If you’re interested, feel free to get in touch with us at sales@zetetic.net.

Read-only database is enough for me. I have some zip compression functions for Sqlite. Could you explain more in details to how enable this read-only compressed database ?
thanks

Hi @ray_pixar,

You mentioned you already have compression functions implemented; in that case compressing your data before you insert it into a table is certainly an option. However, to do it transparently would be much more complex and would probably require considerable engineering. Thus, I’m afraid that we can’t really provide much more in the way of specific guidance on this.