Crates.io | digestible |
lib.rs | digestible |
version | 0.2.2 |
source | src |
created_at | 2023-08-26 16:09:25.727185 |
updated_at | 2023-10-13 12:21:55.879243 |
description | A more dynamic Hash and Hasher trait for Rust |
homepage | |
repository | https://github.com/wyatt-herkamp/digestible |
max_upload_size | |
id | 955596 |
size | 47,764 |
A more dynamic Hash and Hasher trait for Rust
#[digestible(skip)]
#[digestible(type_header = none)]
)no_std
Supportdigest_with
you can add #[digestible(digest_with = digest_with_hash)]
to your variable
to tell Digestible to use Hash to digest it.
Adding #[digestible(hash)]
to your struct or enum will implement Hash for it.
Using the digest function.
Allowing you to have a Hash and Digestible that are the same.
#[derive(Digestible)]
pub struct MyStruct {
pub id: u32,
pub name: String,
#[digestible(skip)]
pub password: String,
}
fn digest_to_bytes(){
let test = MyStruct{
id: 0,
name: "Test".to_string(),
password: "Test".to_string(),
};
let mut hasher = sha2::Sha256::new();
let result = hasher.digest_native(&test); // This will be the type of sha2 Output
}
fn digest_to_base64(){
let test = MyStruct{
id: 0,
name: "Test".to_string(),
password: "Test".to_string(),
};
let hasher = sha2::Sha256::new().into_base64();
let result = hasher.digest_native(&test); // This is a base64 encoded string
}