# Setting up Dbeaver (The Universal DBMS) to work with SqlCipher Databases I’ve tried multiple solutions to browse `SqlCipher` Databases and the only one that seemed to work properly was [DB Sqlite Browser]([DB Browser for SQLite (sqlitebrowser.org)](https://sqlitebrowser.org/)) with easy GUI to get into the db. but … the overall experience of that application didn’t really satisfy me! I knew **DBeaver** from long time ago, and i wondered if i can use it with SQLCipher, but it was surprisingly a shock that it doesn’t work directly, but with a couple of hours of researching and trying different methods i finally came up with a way to configure it Out-of-the box to make it work! The reason I wrote this gist was to help others who have the same issue as it seems there is no guide to show how to do so! So Let's Go ! ## Download & Install Dbeaver 1. head to https://dbeaver.io/ 2. download the one that suits your OS 3. Install ! ## Getting the right driver to get the Job done 1. head to https://github.com/Willena/sqlite-jdbc-crypt/releases and download the latest `sqlite-jdbc-.jar`. 2. copy that file in a safe place on your pc that you DON'T ACCIDENTALY REMOVE ## Linking Everything together Well, there are multiple versions of SQLCipher and in this gist i'll target only SqlCipher V3 but it's the same Idea once you grasp it! ### Creating a custom driver for dbeaver 1. From Database Menu --> Open DriverManager 2. Hit New, and now let‘s configure it #### 1. `Settings` Tab - Driver Name = **SqlCipherV3** (or any name you’d like) - Driver Type, Select Generic - Class Name = `org.sqlite.JDBC` - URL Template = `jdbc:sqlite:{file}` The rest are not mandatory, feel free to setup them up on your own! #### 2. `Libraries` Tab Remember the `.jar` file that we’ve downloaded recently? If your answer was no, please have a look [Getting the right driver](#Getting-the-right-driver-to-get the-Job-done) If your answer was yes, Let‘s continue - Click `Add File` and Select that `.jar` file - Click `Find Class` and select `org.sqlite.JDBC` #### 3. Driver Prosperities Here comes the most important part, make sure that you’ve configured that one properly! > To Add a property, Right-Click and press Add | Key | Value | | -------------------- | ------------- | | **cipher** | **sqlcipher** | | **fast_kdf_iter** | **2** | | **hmac_algorithm** | **0** | | **hmac_pgno** | **1** | | **hmac_salt_mask** | **0x3a** | | **hmac_user** | **1** | | **kdf_iter** | **64000** | | **legacy** | **3** | | **legacy_page_size** | **1024** | There are one more PRAGMA which is called `key` and it is used to pass a passphrase that’s used to decrypt your db, but we won’t set it here as it differs from a database to another For different version parameters of **SqlCipher** visit: https://utelle.github.io/SQLite3MultipleCiphers/docs/ciphers/cipher_sqlcipher/ and actually i’ve acquired the above one from there! | Parameter | v4 | v3 | v2 | v1 | | :---------------------- | :----: | :---: | :--: | :--: | | `kdf_iter` | 256000 | 64000 | 4000 | 4000 | | `fast_kdf_iter` | 2 | 2 | 2 | 2 | | `hmac_use` | 1 | 1 | 1 | 0 | | `hmac_pgno` | 1 | 1 | 1 | n/a | | `hmac_salt_mask` | 0x3a | 0x3a | 0x3a | n/a | | `legacy` | 4 | 3 | 2 | 1 | | `legacy_page_size` | 4096 | 1024 | 1024 | 1024 | | `kdf_algorithm` | 2 | 0 | 0 | 0 | | `hmac_algorithm` | 2 | 0 | 0 | 0 | | `plaintext_header_size` | 0 | n/a | n/a | n/a | > Note: - > > - for `n/a` values don’t enter anything! > - V indicates the **SqlCipher** Version! ## Adding DB to **DBeaver** - From **Database** Menu —> Select **New Database Connection** - Search for **SqlCipherV3** (the one we created recently) and press Next - Click **Browse** and Select your SqlCipher Database file - In **Driver properties** tab make sure that your **defaults** has been set correctly - In `Key` Property double click the Value and Enter your Passphrase - Test Connection, Voila! - Press Finish # Support If you encountered any problem, please feel free to comment below and I’ll gladly help!