Show / Hide Table of Contents

Class HashingAlgorithm

Metadata and implemetations of a IPFS hashing algorithms.

Inheritance
Object
HashingAlgorithm
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Namespace: Ipfs.Registry
Assembly: Ipfs.Core.dll
Syntax
public class HashingAlgorithm
Remarks

IPFS assigns a unique Name and Code to a hashing algorithm. See hashtable.csv for the currently defined hashing algorithms.

These algorithms are implemented:

  • blake2b-160, blake2b-256 blake2b-384 and blake2b-512
  • blake2s-128, blake2s-160, blake2s-224 a nd blake2s-256
  • keccak-224, keccak-256, keccak-384 and keccak-512
  • md4 and md5
  • sha1
  • sha2-256, sha2-512 and dbl-sha2-256
  • sha3-224, sha3-256, sha3-384 and sha3-512
  • shake-128 and shake-256

The identity hash is also implemented; which just returns the input bytes. This is used to inline a small amount of data into a Cid.

Use Register(String, Int32, Int32, Func<HashAlgorithm>) to add a new hashing algorithm.

Properties

| Improve this Doc View Source

All

A sequence consisting of all HashingAlgorithm.

Declaration
public static IEnumerable<HashingAlgorithm> All { get; }
Property Value
Type Description
IEnumerable<HashingAlgorithm>

The currently registered hashing algorithms.

| Improve this Doc View Source

Code

The IPFS number assigned to the hashing algorithm.

Declaration
public int Code { get; }
Property Value
Type Description
Int32

Valid hash codes at hashtable.csv.

| Improve this Doc View Source

DigestSize

The size, in bytes, of the digest value.

Declaration
public int DigestSize { get; }
Property Value
Type Description
Int32

The digest value size in bytes. Zero indicates that the digest is non fixed.

| Improve this Doc View Source

Hasher

Returns a cryptographic hash algorithm that can compute a hash (digest).

Declaration
public Func<HashAlgorithm> Hasher { get; }
Property Value
Type Description
Func<HashAlgorithm>
| Improve this Doc View Source

Name

The name of the algorithm.

Declaration
public string Name { get; }
Property Value
Type Description
String

A unique name.

Methods

| Improve this Doc View Source

Deregister(HashingAlgorithm)

Remove an IPFS hashing algorithm from the registry.

Declaration
public static void Deregister(HashingAlgorithm algorithm)
Parameters
Type Name Description
HashingAlgorithm algorithm

The HashingAlgorithm to remove.

| Improve this Doc View Source

GetAlgorithm(String)

Gets the HashAlgorithm with the specified IPFS multi-hash name.

Declaration
public static HashAlgorithm GetAlgorithm(string name)
Parameters
Type Name Description
String name

The name of a hashing algorithm, see https://github.com/multiformats/multicodec/blob/master/table.csv for IPFS defined names.

Returns
Type Description
HashAlgorithm

The hashing implementation associated with the name.

Exceptions
Type Condition
KeyNotFoundException

When name is not registered.

| Improve this Doc View Source

GetAlgorithmMetadata(String)

Gets the metadata with the specified IPFS multi-hash name.

Declaration
public static HashingAlgorithm GetAlgorithmMetadata(string name)
Parameters
Type Name Description
String name

The name of a hashing algorithm, see https://github.com/multiformats/multicodec/blob/master/table.csv for IPFS defined names.

Returns
Type Description
HashingAlgorithm

The metadata associated with the hashing name.

Exceptions
Type Condition
KeyNotFoundException

When name is not registered.

| Improve this Doc View Source

Register(String, Int32, Int32, Func<HashAlgorithm>)

Register a new IPFS hashing algorithm.

Declaration
public static HashingAlgorithm Register(string name, int code, int digestSize, Func<HashAlgorithm> hasher = null)
Parameters
Type Name Description
String name

The name of the algorithm.

Int32 code

The IPFS number assigned to the hashing algorithm.

Int32 digestSize

The size, in bytes, of the digest value.

Func<HashAlgorithm> hasher

A Func that returns a HashAlgorithm. If not specified, then a Func is created to throw a NotImplementedException.

Returns
Type Description
HashingAlgorithm

A new HashingAlgorithm.

| Improve this Doc View Source

RegisterAlias(String, String)

Register an alias for an IPFS hashing algorithm.

Declaration
public static HashingAlgorithm RegisterAlias(string alias, string name)
Parameters
Type Name Description
String alias

The alias name.

String name

The name of the existing algorithm.

Returns
Type Description
HashingAlgorithm

A new HashingAlgorithm.

| Improve this Doc View Source

ToString()

The Name of the hashing algorithm.

Declaration
public override string ToString()
Returns
Type Description
String
Overrides
Object.ToString()
  • Improve this Doc
  • View Source
Back to top Generated by DocFX