| Crates.io | rust-crypto-utils |
| lib.rs | rust-crypto-utils |
| version | 2.0.0 |
| created_at | 2025-11-18 05:32:40.454185+00 |
| updated_at | 2025-12-11 08:17:22.022644+00 |
| description | Memory-safe cryptographic utilities for secure key handling, encryption, and post-quantum readiness |
| homepage | |
| repository | https://github.com/guardsarm/rust-crypto-utils |
| max_upload_size | |
| id | 1937924 |
| size | 134,713 |
Memory-safe cryptographic utilities for financial systems and secure applications. Built with Rust to eliminate memory vulnerabilities in cryptographic implementations.
Implements cryptographic best practices with automatic memory zeroization and secure key handling. Aligns with NIST cryptographic standards and 2024 CISA/FBI guidance for memory-safe implementations.
Add to your Cargo.toml:
[dependencies]
rust-crypto-utils = "0.1.0"
use rust_crypto_utils::{SecurePassword, password};
// Hash a password
let password = SecurePassword::new(b"UserPassword123!".to_vec());
let hash = password::hash_password(&password).unwrap();
// Verify password
let is_valid = password::verify_password(&password, &hash).unwrap();
assert!(is_valid);
use rust_crypto_utils::{SecureKey, encryption};
// Generate encryption key
let key = SecureKey::generate();
// Encrypt sensitive data
let plaintext = b"Account: 123456, Balance: $50,000";
let encrypted = encryption::encrypt(&key, plaintext).unwrap();
// Decrypt data
let decrypted = encryption::decrypt(&key, &encrypted).unwrap();
assert_eq!(plaintext.as_slice(), decrypted.as_slice());
use rust_crypto_utils::random;
// Generate random bytes
let random_bytes = random::generate_random_bytes(32);
// Generate random hex string (for tokens)
let token = random::generate_random_hex(16); // 32 hex characters
All sensitive types (SecurePassword, SecureKey) automatically zero their memory when dropped:
{
let password = SecurePassword::new(b"secret".to_vec());
// Use password...
} // Memory automatically zeroed here
// Won't compile: key length checked at runtime
let short_key = vec![0u8; 16];
let key = SecureKey::new(short_key); // Returns Err(InvalidKeyLength)
// Correct: 256-bit key
let valid_key = vec![0u8; 32];
let key = SecureKey::new(valid_key).unwrap();
Uses Argon2id with secure default parameters:
See the examples/ directory:
cargo run --example password_hashing
cargo run --example file_encryption
cargo test
This library implements cryptographic best practices from:
Designed for financial institutions requiring:
MIT License - See LICENSE file
Tony Chuks Awunor
Contributions welcome! Please open an issue or pull request.
If you discover a security vulnerability, please email security@example.com (do not open public issue).
If you use this library in research or production systems, please cite:
Awunor, T.C. (2024). Rust Crypto Utils: Memory-Safe Cryptographic Utilities.
https://github.com/guardsarm/rust-crypto-utils
Built for financial security. Designed for memory safety. Implemented in Rust.