Nethermind.Multiformats.Hash
1.5.2
dotnet add package Nethermind.Multiformats.Hash --version 1.5.2
NuGet\Install-Package Nethermind.Multiformats.Hash -Version 1.5.2
<PackageReference Include="Nethermind.Multiformats.Hash" Version="1.5.2" />
paket add Nethermind.Multiformats.Hash --version 1.5.2
#r "nuget: Nethermind.Multiformats.Hash, 1.5.2"
// Install Nethermind.Multiformats.Hash as a Cake Addin #addin nuget:?package=Nethermind.Multiformats.Hash&version=1.5.2 // Install Nethermind.Multiformats.Hash as a Cake Tool #tool nuget:?package=Nethermind.Multiformats.Hash&version=1.5.2
Multiformats Multihash
Multibase implementation in C#.
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
- SKEIN256-(bits) (8-256)
- SKEIN512-(bits) (8-512)
- SKEIN1024-(bits) (8-1024)
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- BinaryEncoding (>= 1.4.0)
- BouncyCastle.Cryptography (>= 2.4.0)
- murmurhash (>= 1.0.2)
- Nethermind.Multiformats.Base (>= 2.0.3-preview.1)
- System.Composition (>= 1.2.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Nethermind.Multiformats.Hash:
Package | Downloads |
---|---|
Nethermind.Multiformats.Address
Multiaddr implementation in C# |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.5.2 | 408 | 7/23/2024 |
1.5.2-preview.1 | 22,562 | 7/23/2024 |