rust-multihash
multihash implementation in Rust.
Table of Contents
Install
First add this to your Cargo.toml
[dependencies]
multihash = "*"Then run cargo build.
Usage
use multihash::{Code, MultihashCode};
fn main() {
let hash = Code::Sha2_256.digest(b"my hash");
println!("{:?}", hash);
}Using a custom code table
You can derive your own application specific code table:
use multihash::derive::Multihash;
use multihash::{MultihashCode, U32, U64};
#[derive(Clone, Copy, Debug, Eq, Multihash, PartialEq)]
#[mh(alloc_size = U64)]
pub enum Code {
#[mh(code = 0x01, hasher = multihash::Sha2_256, digest = multihash::Sha2Digest<U32>)]
Foo,
#[mh(code = 0x02, hasher = multihash::Sha2_512, digest = multihash::Sha2Digest<U64>)]
Bar,
}
fn main() {
let hash = Code::Foo.digest(b"my hash");
println!("{:02x?}", hash);
}Supported Hash Types
SHA1SHA2-256SHA2-512SHA3/KeccakBlake2b-256/Blake2b-512/Blake2s-128/Blake2s-256Blake3Strobe
Maintainers
Captain: @dignifiedquire.
Contribute
Contributions welcome. Please check out the issues.
Check out our contributing document for more information on how we work, and about contributing in general. Please be aware that all interactions related to multiformats are subject to the IPFS Code of Conduct.
Small note: If editing the README, please conform to the standard-readme specification.

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
