Cannot encrypt a database

156 views
Skip to first unread message

Masrur Mahmood

unread,
May 11, 2015, 11:43:34 AM5/11/15
to sqlc...@googlegroups.com
Hello All,

I'm having a strange problem with SQLCipher where I'm trying to encrypt an existing SQLite3 database. I'm on Ubuntu 12.04 64-bit OS with GCC 4.6.3.

Let me tell you what I've done so far. I compiled SQLCipher as follows:
~/Downloads/sqlcipher: ./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="-lcrypto" --prefix=/usr
~/Downloads/sqlcipher: make
~/Downloads/sqlcipher: sudo make install

Now, I launch sqlcipher and issue the command (my database name is test.db):
./sqlcipher plaintext.db
sqlite> ATTACH DATABASE 'test.db' AS encrypted KEY 'secret';
Error: file is encrypted or is not a database

There is no information about what the error is. Anyone have any idea? I can open the database and run SQL statements but I'm getting an error when I try to encrypt it.

Please advice.

Masrur Mahmood

unread,
May 11, 2015, 11:44:55 AM5/11/15
to sqlc...@googlegroups.com
Sorry meant to say:
./sqlcipher test.db on that line above.

Nick Parker

unread,
May 11, 2015, 11:53:06 AM5/11/15
to sqlc...@googlegroups.com

Hello Masrur,

To verify the environment is correct, can you execute "PRAGMA cipher_version;" once you launch the SQLCipher command line shell and provide the output? Thanks

--


You received this message because you are subscribed to the Google Groups "SQLCipher Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlcipher+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nick Parker

signature.asc

Masrur Mahmood

unread,
May 11, 2015, 12:21:54 PM5/11/15
to sqlc...@googlegroups.com
When I run the PRAGMA cipher_version, it returns: 3.3.0

Nick Parker

unread,
May 11, 2015, 12:56:28 PM5/11/15
to sqlc...@googlegroups.com

Hello Masrur,

You will need to perform the attach to another file, not the existing plain text database if you are trying to perform an export to an encrypted database. You can of course delete the original plain text file and rename the encrypted after the export completes. Please take a look at example 1 for the sqlcipher_export documentation here [1].

[1] https://www.zetetic.net/sqlcipher/sqlcipher-api/#sqlcipher_export

You received this message because you are subscribed to the Google Groups


"SQLCipher Users" group.
To unsubscribe from this group and stop receiving emails from it, send an

email to sqlcipher+...@googlegroups.com <javascript:>.


For more options, visit https://groups.google.com/d/optout.

Nick Parker

--


You received this message because you are subscribed to the Google Groups "SQLCipher Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlcipher+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nick Parker

signature.asc

Masrur Mahmood

unread,
May 11, 2015, 1:09:46 PM5/11/15
to sqlc...@googlegroups.com
Thank you Nick.

From the API documentation, it wasn't clear that we open the unencrypted database and then use those commands that will be used to create to a new encrypted database file. 
It seems to work now.

Nick Parker

unread,
May 11, 2015, 1:16:29 PM5/11/15
to sqlc...@googlegroups.com

Hello Masrur,

I am glad to hear everything is working for you now.

signature.asc
Reply all
Reply to author
Forward
0 new messages