Crates.io | dispnet-hash |
lib.rs | dispnet-hash |
version | 0.4.0 |
source | src |
created_at | 2022-03-09 19:14:41.583102 |
updated_at | 2023-06-25 16:20:24.551407 |
description | Hash Library used for Dispnet |
homepage | https://github.com/Chtau/dispnet-hash |
repository | https://github.com/Chtau/dispnet-hash |
max_upload_size | |
id | 547123 |
size | 32,510 |
Dispnet Hash produces a self descripting hash for easy backwards compatibility. The hash format follows the TLV (type-length-value) pattern.
<type><bytes-length><value>
01 0032 4878ca0425c739fa427f7eda20fe845f6b2e46ba5fe2a14df5b1e32f50603215
02 0010 32323538363632303830
03 0084 246172676f6e326924763d3139246d3d343039362c743d332c703d31244d54497a4e4455324e7a6724686f56354d494638596a39746b39356c467365546279554a6e393336484944586754685533637065643151
Type | Bytes length | Hash
let dispnet_hash = DispnetHash::new("test".as_bytes());
let display_hash = format!("{}", dispnet_hash);
assert_eq!(display_hash, "0100324878ca0425c739fa427f7eda20fe845f6b2e46ba5fe2a14df5b1e32f50603215");
let dispnet_hash = DispnetHash::create(HashType::CRC, "test".as_bytes(), None);
let display_hash = format!("{}", dispnet_hash);
assert_eq!(display_hash, "02001032323538363632303830");
let dispnet_hash = "0100324878ca0425c739fa427f7eda20fe845f6b2e46ba5fe2a14df5b1e32f50603215".parse::<DispnetHash>().unwrap();
assert_eq!(dispnet_hash.hash_type, HashType::Blake3);
assert_eq!(dispnet_hash.digest_length, 32);
assert_eq!(dispnet_hash.digest_value.len(), 32);
assert!(DispnetHash::verify("030084246172676f6e326924763d3139246d3d343039362c743d332c703d31244d54497a4e4455324e7a6724686f56354d494638596a39746b39356c467365546279554a6e393336484944586754685533637065643151", "test".as_bytes()));
cargo build
cargo test
cargo bench
View Html report in target/criterion/report/index.html
Created with Criterion.rs
cargo publish --dry-run
License MIT