redbx

Crates.ioredbx
lib.rsredbx
version3.0.1
created_at2025-09-10 09:25:06.056577+00
updated_at2025-09-10 09:25:06.056577+00
descriptionRust Embedded DataBase with AES Encryption - Fork of redb
homepagehttps://redbx.inoerawan.id
repositoryhttps://github.com/inoerawan/redbx
max_upload_size
id1832282
size1,016,802
(abeinoe)

documentation

README

redbx

License

A simple, portable, high-performance, ACID, embedded key-value store with built-in AES encryption.

redbx is a fork of redb that provides transparent encryption for all user data. It's written in pure Rust and is loosely inspired by lmdb. Data is stored in a collection of copy-on-write B-trees with AES-256-GCM encryption. For more details, see the design doc

Key Features

  • Built-in AES-256-GCM encryption for all user data
  • PBKDF2-SHA256 key derivation with 100,000 iterations
  • Transparent encryption/decryption at the storage layer
  • Zero-copy, thread-safe, BTreeMap based API
  • Fully ACID-compliant transactions
  • MVCC support for concurrent readers & writers, without blocking
  • Crash-safe by default
  • Savepoints and rollbacks
use redbx::{Database, Error, ReadableTable, TableDefinition};

const TABLE: TableDefinition<&str, u64> = TableDefinition::new("my_data");

fn main() -> Result<(), Error> {
    // Create an encrypted database with a password
    let db = Database::create("my_db.redbx", "my_secure_password")?;
    let write_txn = db.begin_write()?;
    {
        let mut table = write_txn.open_table(TABLE)?;
        table.insert("my_key", &123)?;
    }
    write_txn.commit()?;

    // Open the encrypted database with the same password
    let db = Database::open("my_db.redbx", "my_secure_password")?;
    let read_txn = db.begin_read()?;
    let table = read_txn.open_table(TABLE)?;
    assert_eq!(table.get("my_key")?.unwrap().value(), 123);

    Ok(())
}

Features

  • Zero-copy, thread-safe, BTreeMap based API
  • Fully ACID-compliant transactions
  • MVCC support for concurrent readers & writer, without blocking
  • Crash-safe by default
  • Savepoints and rollbacks
  • Built-in AES-256-GCM encryption for all user data
  • PBKDF2-SHA256 key derivation with 100,000 iterations
  • Transparent encryption/decryption at the storage layer

Development

To run all the tests and benchmarks a few extra dependencies are required:

# Install dependencies
sudo apt-get install libclang-dev

# Run tests
cargo test

# Run benchmarks
cd crates/redbx-bench
cargo bench --bench encryption_overhead_benchmark

Known problem

  • lack of performance, work in progress.

License

Licensed under either of

at your option.

Security

redbx uses industry-standard cryptographic algorithms:

  • AES-256-GCM for authenticated encryption
  • PBKDF2-SHA256 with 100,000 iterations for key derivation
  • Cryptographically secure random salt generation

All user data is encrypted at rest, while metadata remains unencrypted for performance and debugging purposes.

Migration from redb

redbx is designed to be a drop-in replacement for redb with the addition of password-based encryption:

// redb (unencrypted)
let db = Database::create("db.redb")?;

// redbx (encrypted)
let db = Database::create("db.redbx", "password")?;

The API is otherwise identical, making migration straightforward.

Commit count: 1389

cargo fmt