Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Miniontoby/8c23b051824f7e357d8b319fad12315b to your computer and use it in GitHub Desktop.
Save Miniontoby/8c23b051824f7e357d8b319fad12315b to your computer and use it in GitHub Desktop.
Using SQLite3MultipleCiphers with rusqlite. RC4 encryption support and more!

Use SQLite3MultipleCiphers with rusqlite

Why would you?

If you're working in Rust and you need to read a System.Data.SQLite: RC4 database, or any of the other supported ciphers, then that's not possible with the "bundled" feature of rusqlite.

SQLite3MultipleCiphers is an extension for sqlite3 and can be used as a drop-in replacement for SQLite.

I personally had some trouble getting it to work, so now that I found out how you're supposed to do it, I decided to make a guide.

Guide

Windows

  1. Download the sqlite3mc-x.x.x-sqlite-x.x.x-win64.zip from the SQLite3MultipleCiphers releases.

  2. Unarchive the downloaded zip and open the dll folder.

  3. Copy the sqlite3mc_x64.lib and sqlite3mc_x64.dll files to your rust project folder, the folder with the Cargo.toml file.

  4. Rename the sqlite3mc_x64.lib to sqlite3.lib, and leave the other file as it is.

  5. Install rusqlite without features enabled: cargo add rusqlite

  6. Add the code to use rc4:

let newconn  = Connection::open("database.sqlite").unwrap();
newconn.pragma_update(None, "cipher", "rc4").unwrap();
newconn.pragma_update(None, "key", &"your_password").unwrap();
  1. Start your project: cargo run

You should now be able to read and write to rc4 encrypted databases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment