Crates.io | hmac-sha |
lib.rs | hmac-sha |
version | 0.6.1 |
source | src |
created_at | 2021-07-20 15:00:25.447673 |
updated_at | 2021-11-02 08:06:56.596371 |
description | Minimal wrapper of HMAC-SHA-{1,2,3} in Rust. |
homepage | |
repository | https://github.com/lrazovic/rust-hmac-sha |
max_upload_size | |
id | 425188 |
size | 9,142 |
A pure Rust implementation of the Hash-based Message Authentication Code Algoritm for SHA-{1,2,3}. This project can be seen as an interface/wrapper for the RustCrypto crate,
focusing on user/developer ease of use.
Works in a #![no_std]
environment.
This repo is a fork of Rust-HMAC-SHA1 by @pantsman0/Philip Woolford. Unlike the original version, it supports SHA-2 and SHA-3 in addition to SHA-1. In addition this fork uses the implementations of SHA provided by RustCrypto. Has been developed to assist in the development of OOTP.
To import rust-hmac-sha
add the following to your Cargo.toml:
[dependencies]
hmac-sha = "0.6"
and any other Hash crate that statisfy the Digest
trait, like sha3
[dependencies]
...
sha3 = { version = "0.9", default-features = false }
You can use rust-hmac-sha
in this way:
use hex;
use hmacsha::HmacSha;
use sha3::Sha3_256;
fn main() {
let secret_key = "A very strong secret";
let message = "My secret message";
let mut hasher = HmacSha::from(secret_key, message, Sha3_256::default());
let result = hasher.compute_digest();
println!("{}", hex::encode(result));
}
Any contributions are welcome. This was implemented as a learning experience and any advice is appreciated.
This crate is licensed under the MIT or Apache licenses, as is its dependancies of the RustCrypto family. The original crate was licensed under the BSD 3-Clause license, as the old dependency sha1