32 releases

new 0.16.3 Aug 11, 2022
0.16.2 Mar 31, 2022
0.16.1 Feb 4, 2022
0.15.0 Oct 4, 2021
0.1.0 Dec 28, 2015

#9 in Magic Beans

Download history 37700/week @ 2022-04-23 34764/week @ 2022-04-30 37192/week @ 2022-05-07 39851/week @ 2022-05-14 36486/week @ 2022-05-21 34181/week @ 2022-05-28 34785/week @ 2022-06-04 37575/week @ 2022-06-11 35944/week @ 2022-06-18 33978/week @ 2022-06-25 33059/week @ 2022-07-02 33782/week @ 2022-07-09 40252/week @ 2022-07-16 39040/week @ 2022-07-23 44204/week @ 2022-07-30 36933/week @ 2022-08-06

166,506 downloads per month
Used in 471 crates (82 directly)

MIT license

42KB
765 lines

rust-multihash

Build Status Crates.io License Documentation Dependency Status Coverage Status

multihash implementation in Rust.

Table of Contents

Install

First add this to your Cargo.toml

[dependencies]
multihash = "*"

Then run cargo build.

MSRV 1.51.0 due to use of const generics

Usage

use multihash::{Code, MultihashDigest};

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;

#[derive(Clone, Copy, Debug, Eq, Multihash, PartialEq)]
#[mh(alloc_size = 64)]
pub enum Code {
    #[mh(code = 0x01, hasher = multihash::Sha2_256)]
    Foo,
    #[mh(code = 0x02, hasher = multihash::Sha2_512)]
    Bar,
}

fn main() {
    let hash = Code::Foo.digest(b"my hash");
    println!("{:02x?}", hash);
}

Supported Hash Types

  • SHA1
  • SHA2-256
  • SHA2-512
  • SHA3/Keccak
  • Blake2b-256/Blake2b-512/Blake2s-128/Blake2s-256
  • Blake3
  • Strobe

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.

License

MIT

Dependencies

~0.3–1.5MB
~27K SLoC