Re: Decrypt an SQLCipher Encrypted Database externally

1,680 views
Skip to first unread message

Stephen Lombardo

unread,
Mar 22, 2012, 10:28:07 AM3/22/12
to sqlc...@googlegroups.com
Hi Vivek,

I haven't had the time to update decrypt.c in the tools package for the new sqlcipher 2 database format. It's not that high on our priority list either at this point, especially given the improvements to attach an sqlcipher_export in version 2.0, which make it largely unnecessary. You should be able to decrypt a database on the computer simply by doing:

new-host-2% ./sqlite3 encrypted.db
sqlite> PRAGMA key = 'test123';
sqlite> ATTACH DATABASE 'unencrypted.db' AS unencrypted KEY '';
sqlite> SELECT sqlcipher_export('unencrypted');
sqlite> .q

new-host-2% ./sqlite3 unencrypted.db
sqlite> .schema
CREATE TABLE secrets(id, password, key);

Technically this doesn't really strip the encryption off the database like decrypt.c did. Instead, it exports an unencrypted copy of the schema and data. Even so, the effect is the same, so decrypt.c is of much less value now. 

Will this approach work for you?

Cheers,
Stephen

On Wed, Mar 21, 2012 at 1:35 PM, Vivek Anand <y.vive...@gmail.com> wrote:
I am currently using SQLCipher for my Iphone project and the version
of SQLCipher I use is the latest (3.7.10). I guess that is the version
that is packaged with the iOS version of SQLCipher.
There was a file under the tools which is decrypt.c which was used to
decrypt the files encrypted using SQLCipher but the documentation for
this file says that it can open only version 1 database.
But i went ahead and tried to use this tool to decrypt my database but
it gave me a segmentation error.

Is there a latest version of this file that can be used for higher
versions of SQLCipher?

The error that I am getting is because of decrypt.c not supporting
higher versions of DB or some error from my end?

Vivek Anand

unread,
Mar 22, 2012, 10:37:24 AM3/22/12
to sqlc...@googlegroups.com
Hi,

Thanks for your reply.
What I did was i turned HMAC off for the latest version in my app code.
I learnt that this gives backward compatibility to the current version of SQLCipher.

After this I was able to run the decrypt.c and get the expected output.
Also it is good to know that there is another standard approach for this.

In the meanwhile can you point me to some resource,if any, which has a list of SQLCipher command i.e. one specifically added by sqlcipher such as the export command you mentioned.

Thanks,
VIVEK
--
Regards,
VIVEK

Stephen Lombardo

unread,
Mar 28, 2012, 1:34:41 AM3/28/12
to sqlc...@googlegroups.com
Hi Vivek,

On Thu, Mar 22, 2012 at 10:37 AM, Vivek Anand <y.vive...@gmail.com> wrote:

In the meanwhile can you point me to some resource,if any, which has a list of SQLCipher command i.e. one specifically added by sqlcipher such as the export command you mentioned.

The recent changes to the API page document all of the extensions / functions introduced by SQLCipher along with relevant examples:


Please take a look and let use know if you have any questions, feedback is welcome.

Cheers,
Stephen
Reply all
Reply to author
Forward
0 new messages