https://github.com/ankddev/lonesha256
Rust bindings for the lonesha256 C library
https://github.com/ankddev/lonesha256
Last synced: about 1 year ago
JSON representation
Rust bindings for the lonesha256 C library
- Host: GitHub
- URL: https://github.com/ankddev/lonesha256
- Owner: ankddev
- License: mit
- Created: 2025-02-13T05:15:30.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-07T02:58:02.000Z (about 1 year ago)
- Last Synced: 2025-04-07T03:31:42.479Z (about 1 year ago)
- Language: Rust
- Size: 66.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lonesha256
[](https://crates.io/crates/lonesha256)
[](https://crates.io/crates/lonesha256)
Rust bindings for the lonesha256 C library - a portable, endian-proof, single-file SHA256 implementation.
## About
This crate provides Rust bindings for [lonesha256](https://github.com/BareRose/lonesha256), making it easy to use this lightweight SHA256 implementation in your Rust projects.
## Installation
Add this to your `Cargo.toml`:
```toml
[dependencies]
lonesha256 = "1.1.0"
```
or run this command in your terminal:
```sh
cargo add lonesha256
```
## Usage
```rust
use 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::());
}
```
## Documentation
Library documentation can be found [here](https://docs.rs/lonesha256/latest/lonesha256/)
## Features
- Lightweight SHA256 implementation
- No external dependencies
- Safe Rust wrapper around C code
- Comprehensive test suite
- Multiple usage examples
## Building from Source
1. Install `clang`, as said [here](https://rust-lang.github.io/rust-bindgen/requirements.html)
2. Clone the repository:
```
git clone https://github.com/ankddev/lonesha256
cd lonesha256
```
3. Build:
```
cargo build --release
```
## Examples
Run the included examples:
```sh
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 testing
```
## Testing
Run the test suite:
```
cargo test
```
## Contributing
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Author
[ANKDDEV](https://github.com/ankddev)
## Acknowledgments
- [lonesha256](https://github.com/BareRose/lonesha256) - Original C implementation by [BareRose](https://github.com/BareRose)