Multihash implementation in C#
Clone or download
tabrath fix: scripts
License: MIT
Signed-off-by: Trond Bråthen <tabrath@gmail.com>
Latest commit bc5b289 May 23, 2018
Permalink
Failed to load latest commit information.
lib Upgrade May 10, 2017
src fix: ignore warnings May 23, 2018
test/Multiformats.Hash.Tests fix: ignore warnings May 23, 2018
.gitattributes initial Oct 30, 2016
.gitignore Upgrade May 10, 2017
.gitmodules Upgrade May 10, 2017
.travis.yml fix: scripts May 23, 2018
LICENSE created readme and license Oct 30, 2016
Multiformats.Hash.sln Fix xunit path Feb 10, 2018
NuGet.config Upgrade May 10, 2017
README.md chore: update readme May 20, 2018
appveyor.yml fix: more build script fixes May 23, 2018
build.sh fix: scripts May 23, 2018
multihash fix: scripts May 23, 2018

README.md

Multiformats.Hash (cs-multihash)

Travis CI AppVeyor NuGet Codecov Libraries.io

Multihash implementation in C# .NET Standard 1.6 compliant.

This is not a general purpose hashing library, but a library to encode/decode Multihashes which is a "container" describing what hash algorithm the digest is calculated with. The library also support calculating the digest, but that is not it's main purpose. If you're looking for a library that supports many algorithms and only want the raw digest, try BouncyCastle or the built-ins of the .net framework.

To be clear, when you calculate a digest (using Sum) with this library, you will get a byte array including a prefix with the properties of the algorithm used (type and length).

There's a CLI version that you can use to compute files or direct input from the command line. This CLI tool passes the sharness tests here.

Table of Contents

Install

PM> Install-Package Multiformats.Hash

dotnet add package Multiformats.Hash

Usage

// decode a multihash formatted byte array
Multihash mh = Multihash.Decode(bytes);

// decode a multihash formatted string
Multihash mh = Multihash.Parse(str);
bool ok = Multihash.TryParse(str, out mh);

// encode a digest to multiformat byte array
byte[] bytes = Multihash.Encode(digest, HashType.SHA1);
byte[] bytes = Multihash.Encode<SHA1>(digest);

// calculate digest
Multihash mh = Multihash.Sum<SHA1>(bytes);

// verify
bool isValid = mh.Verify(bytes);

Supported hash algorithms

  • ID
  • MD4
  • MD5
  • SHA1
  • SHA2_256
  • SHA2_512
  • SHA3_224
  • SHA3_256
  • SHA3_384
  • SHA3_512
  • SHAKE_128
  • SHAKE_256
  • KECCAK_224
  • KECCAK_256
  • KECCAK_384
  • KECCAK_512
  • BLAKE2B-(bits) (8-512)
  • BLAKE2S-(bits) (8-256)
  • DBL_SHA2_256
  • MURMUR3_32/128

Maintainers

Captain: @tabrath.

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 © 2017-2018 Trond Bråthen

Blake2B © 2017 Uli Riehm