Rust bindings for the lonesha256 C library - a portable, endian-proof, single-file SHA256 implementation.
This crate provides Rust bindings for lonesha256, making it easy to use this lightweight SHA256 implementation in your Rust projects.
Add this to your Cargo.toml:
[dependencies]
lonesha256 = "1.1.0"or run this command in your terminal:
cargo add lonesha256use lonesha256::lonesha256;
fn main() {
    let input = b"Hello, world!";
    let mut hash = [0u8; 32];
    
    lonesha256(&mut hash, input).expect("Failed to compute hash");
    
    println!("Hash: {}", 
        hash.iter()
            .map(|b| format!("{:02x}", b))
            .collect::<String>());
}Library documentation can be found here
- Lightweight SHA256 implementation
 - No external dependencies
 - Safe Rust wrapper around C code
 - Comprehensive test suite
 - Multiple usage examples
 
- Install 
clang, as said here - Clone the repository:
 
git clone https://github.com/ankddev/lonesha256
cd lonesha256
- Build:
 
cargo build --release
Run the included examples:
cargo run --example sample       # Basic usage
cargo run --example file_hash   # File hashing
cargo run --example streaming   # Process data in chunks
cargo run --example hex_output # Different output formats
cargo run --example benchmark  # Performance testingRun the test suite:
cargo test
- Fork the repository
 - Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
 
This project is licensed under the MIT License - see the LICENSE file for details.
- lonesha256 - Original C implementation by BareRose