-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add ripemd family of hashes * revert accidental core2 dep change * rustfmt * add ripemd tests - removes it from default features, - adds a simple helper function for writing new tests (generating multihashes out of band) * rustfmt * fix clippy warnings * CI i stg just let me make a PR, rustfmt * move util to examples
- Loading branch information
Showing
7 changed files
with
122 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use multihash::{Code, MultihashDigest}; | ||
|
||
/// prefix/multihash generating tool to aid when adding new tests | ||
fn prefix_util() { | ||
use unsigned_varint::encode; | ||
// change these as needed | ||
let empty = Code::Sha2_256.wrap(&[]).unwrap().to_bytes(); | ||
let hash = "7c8357577f51d4f0a8d393aa1aaafb28863d9421"; | ||
|
||
// encode things | ||
let len = (hash.len() / 2) as u64; // always hex so len bytes is always half | ||
let mut buf = encode::u64_buffer(); | ||
let len = encode::u64(len, &mut buf); | ||
|
||
let code_hex = hex::encode(&empty[..1]); // change if longer/shorter prefix | ||
let len_hex = hex::encode(len); | ||
println!("prefix hex: code: {}, len: {}", code_hex, len_hex); | ||
|
||
println!("{}{}{}", code_hex, len_hex, hash); | ||
} | ||
|
||
fn main() { | ||
prefix_util() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters