How to use ZeosLib to access SQLCipher encrypted database

Forum related to SQLite

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
abc1849
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: 17.11.2021, 15:29

How to use ZeosLib to access SQLCipher encrypted database

Post by abc1849 »

Hello everyone, I have a database encrypted by the commercial version of the SQLCipher library. Before I used the UniDAC component to access this database, there is a CipherLicense attribute in the database connection properties, and the authorization key of the commercial version of the SQLCipher library can be set.

However, the authorization of UniDAC has expired recently, so I want to switch to the database connection component of ZeosLib, but I did not find similar properties that can set the authorization key of the SQLCipher library in the database connection properties.

I want to know if there is a way to access it using ZeosLib The database encrypted by the commercial SQLCipher library.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1935
Joined: 17.01.2011, 14:17

Re: How to use ZeosLib to access SQLCipher encrypted database

Post by marsupilami »

Hello abc1849,

I had a quick look at SQLCiper by Zetetic. But I couldn't find anything API related to an authorization key. So honestly I cannot say, how to do what you want.

Best regards,

Jan
abc1849
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: 17.11.2021, 15:29

Re: How to use ZeosLib to access SQLCipher encrypted database

Post by abc1849 »

Hi marsupilami,

Thank you for your attention.

There is a description of the relevant authorization key on the download page of the commercial version of SQLCipher I currently use:

In UniDAC's SQLite provider, there is also the attribute of the commercial version of the SQLCipher library authorization key (https://www.devart.com/unidac/docs/using-sqlite.htm):

I'm not sure whether Zeos can support the commercial SQLCipher library. If not, do you have plans to support it?

PS: If necessary, I can send you a copy of SQLCipher library.
abc1849
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: 17.11.2021, 15:29

Re: How to use ZeosLib to access SQLCipher encrypted database

Post by abc1849 »

Sorry, I am not yet familiar with how to add pictures. This is the description of the SQLCipher authorization key:

This is the description of the commercial version of SQLCipher authorization in the UniDAC database connection properties:
You do not have the required permissions to view the files attached to this post.
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 786
Joined: 18.11.2018, 17:37
Location: Hungary

Re: How to use ZeosLib to access SQLCipher encrypted database

Post by aehimself »

You can try to set Encrypted=True in the connection properties and add the key in the password. I'm not sure it'll work (as it calls sqlite3_key) but maybe.
On the other hand, if it's a simple PRAGMA command it's not hard to implement it.
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1935
Joined: 17.01.2011, 14:17

Re: How to use ZeosLib to access SQLCipher encrypted database

Post by marsupilami »

*sigh* - it seems to be a simple pragma - according to the second screenshot. Zeos doesn't support that pragma yet. I wish all those encryption solutions for SQLite would adhere to the same API...
abc1849
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: 17.11.2021, 15:29

Re: How to use ZeosLib to access SQLCipher encrypted database

Post by abc1849 »

Hi aehimself,

I tried the method you mentioned, but the result failed. When opening the connection, it prompts: SQL Error: file is not a database.

Thank you aehimself and marsupilami, maybe marsupilami is right, Zeos does not support the commercial version of the sqlcipher library.

If Zeos developers can consider supporting the sqlcipher library, then it must be the best data access component.
Post Reply