Crates.io | redbx |
lib.rs | redbx |
version | 3.0.1 |
created_at | 2025-09-10 09:25:06.056577+00 |
updated_at | 2025-09-10 09:25:06.056577+00 |
description | Rust Embedded DataBase with AES Encryption - Fork of redb |
homepage | https://redbx.inoerawan.id |
repository | https://github.com/inoerawan/redbx |
max_upload_size | |
id | 1832282 |
size | 1,016,802 |
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
BTreeMap
based APIuse 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(())
}
BTreeMap
based APITo 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
Licensed under either of
at your option.
redbx uses industry-standard cryptographic algorithms:
All user data is encrypted at rest, while metadata remains unencrypted for performance and debugging purposes.
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.