Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scrogson/lockbox
https://github.com/scrogson/lockbox
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/scrogson/lockbox
- Owner: scrogson
- Created: 2024-09-13T02:06:03.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-09-13T13:30:49.000Z (3 months ago)
- Last Synced: 2024-10-08T18:21:31.300Z (3 months ago)
- Language: Rust
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Lockbox
`Lockbox` is a Rust library that provides easy-to-use, secure, and efficient
encryption and decryption using the AES-GCM (Galois/Counter Mode) algorithm.It ensures data integrity and confidentiality while offering flexibility for
various use cases.## Features
- Simple and intuitive API for encrypting and decrypting data.
- Support for customizable tags, Additional Authenticated Data (AAD), and Initialization Vectors (IV).
- Secure default settings to avoid common cryptographic pitfalls.
- Error handling with detailed, meaningful messages.## Installation
To use `Lockbox` in your Rust project, add the following to your `Cargo.toml`:
```toml
[dependencies]
lockbox = "0.1"
```## Getting Started
Here’s a quick example to get you started with `Lockbox`:
```rust
use lockbox::Vault;fn main() -> Result<(), Box> {
// Generate a random key
// This is for demo purposes. In a real situation you'll want to
// use a stable key.
let key = lockbox::generate_key();// Initialize a vault with the key and a tag
let vault = Vault::new(&key, "AES.GCM.V1");// Encrypt some plaintext
let plaintext = b"Hello, secure world!";
let encrypted = vault.encrypt(plaintext)?;
println!("Encrypted: {:?}", encrypted);// Decrypt the ciphertext
let decrypted = vault.decrypt(&encrypted)?;
println!("Decrypted: {}", String::from_utf8(decrypted)?);Ok(())
}
```