Class HashingAlgorithm
Metadata and implemetations of a IPFS hashing algorithms.
Inherited Members
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 SourceAll
A sequence consisting of all HashingAlgorithm.
Declaration
public static IEnumerable<HashingAlgorithm> All { get; }
Property Value
Type | Description |
---|---|
IEnumerable<HashingAlgorithm> | The currently registered hashing algorithms. |
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. |
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. |
Hasher
Returns a cryptographic hash algorithm that can compute a hash (digest).
Declaration
public Func<HashAlgorithm> Hasher { get; }
Property Value
Type | Description |
---|---|
Func<HashAlgorithm> |
Name
The name of the algorithm.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
String | A unique name. |
Methods
| Improve this Doc View SourceDeregister(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. |
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 |
Exceptions
Type | Condition |
---|---|
KeyNotFoundException | When |
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 |
Exceptions
Type | Condition |
---|---|
KeyNotFoundException | When |
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 |
Returns
Type | Description |
---|---|
HashingAlgorithm | A new HashingAlgorithm. |
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. |
ToString()
The Name of the hashing algorithm.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |