C# Class Ipfs.MultiHash

A protocol for differentiating outputs from various well-established cryptographic hash functions, addressing size + encoding considerations.
Afficher le fichier Open project: richardschneider/net-ipfs-core Class Usage Examples

Méthodes publiques

Свойство Type Description
UnknownHashingAlgorithm EventHandler

Méthodes publiques

Méthode Description
ComputeHash ( Stream data, string algorithmName = DefaultAlgorithmName ) : MultiHash

Generate the multihash for the specified data.

ComputeHash ( byte data, string algorithmName = DefaultAlgorithmName ) : MultiHash

Generate the multihash for the specified data.

GetHashAlgorithm ( string name = DefaultAlgorithmName ) : HashAlgorithm

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

Matches ( Stream data ) : bool

Determines if the stream data matches the hash.

Matches is used to ensure data integrity.

Matches ( byte data ) : bool

Determines if the data matches the hash.

Matches is used to ensure data integrity.

MultiHash ( CodedInputStream stream ) : System

Creates a new instance of the MultiHash class from the specified CodedInputStream.

Reads the binary representation of MultiHash from the stream.

The binary representation is a 1-byte HashingAlgorithm.Code, 1-byte HashingAlgorithm.DigestSize followed by the Digest.

When an unknown hashing algorithm number is encountered a new HashingAlgorithm.Register is defined. This algorithm does not support matching nor computing a hash.

This behaviour allows parsing of any well formed MultiHash even when the hashing algorithm is unknown.

MultiHash ( Stream stream ) : System

Creates a new instance of the MultiHash class from the specified Stream.

Reads the binary representation of MultiHash from the stream.

The binary representation is a 1-byte HashingAlgorithm.Code, 1-byte HashingAlgorithm.DigestSize followed by the Digest.

When an unknown hashing algorithm number is encountered a new HashingAlgorithm.Register is defined. This algorithm does not support matching nor computing a hash.

This behaviour allows parsing of any well formed MultiHash even when the hashing algorithm is unknown.

MultiHash ( string s ) : System

Creates a new instance of the MultiHash class from the specified Base58 encoded string.

When an unknown hashing algorithm number is encountered a new HashingAlgorithm.Register is defined. This algorithm does not support matching nor computing a hash.

This behaviour allows parsing of any well formed MultiHash even when the hashing algorithm is unknown.

MultiHash ( string algorithmName, byte digest ) : System

Creates a new instance of the MultiHash class with the specified HashingAlgorithm">Algorithm name and

RaiseUnknownHashingAlgorithm ( HashingAlgorithm algorithm ) : void
Read ( CodedInputStream stream ) : void
Read ( Stream stream ) : void
ToArray ( ) : byte[]

Returns the IPFS binary representation as a byte array.

The binary representation is a sequence of MultiHash.

ToBase58 ( ) : string

Returns the Base58 encoding of the MultiHash.

ToString ( ) : string

Returns the Base58 encoding of the MultiHash.

Write ( CodedOutputStream stream ) : void

Writes the binary representation to the specified CodedOutputStream.

The binary representation is a 1-byte HashingAlgorithm.Code, 1-byte HashingAlgorithm.DigestSize followed by the Digest.

Write ( Stream stream ) : void

Writes the binary representation to the specified Stream.

The binary representation is a 1-byte HashingAlgorithm.Code, 1-byte HashingAlgorithm.DigestSize followed by the Digest.

Private Methods

Méthode Description
MultiHash ( ) : System

Register the standard hash algorithms for IPFS.

Method Details

ComputeHash() public static méthode

Generate the multihash for the specified data.
public static ComputeHash ( Stream data, string algorithmName = DefaultAlgorithmName ) : MultiHash
data Stream /// The containing the data to hash. ///
algorithmName string /// The name of the hashing algorithm to use; defaults to . ///
Résultat MultiHash

ComputeHash() public static méthode

Generate the multihash for the specified data.
public static ComputeHash ( byte data, string algorithmName = DefaultAlgorithmName ) : MultiHash
data byte /// The containing the data to hash. ///
algorithmName string /// The name of the hashing algorithm to use; defaults to . ///
Résultat MultiHash

GetHashAlgorithm() public static méthode

Gets the HashAlgorithm with the specified IPFS multi-hash name.
public static GetHashAlgorithm ( string name = DefaultAlgorithmName ) : HashAlgorithm
name string
Résultat System.Security.Cryptography.HashAlgorithm

Matches() public méthode

Determines if the stream data matches the hash.
Matches is used to ensure data integrity.
public Matches ( Stream data ) : bool
data Stream /// The containing the data to check. ///
Résultat bool

Matches() public méthode

Determines if the data matches the hash.
Matches is used to ensure data integrity.
public Matches ( byte data ) : bool
data byte /// The data to check. ///
Résultat bool

MultiHash() public méthode

Creates a new instance of the MultiHash class from the specified CodedInputStream.
Reads the binary representation of MultiHash from the stream.

The binary representation is a 1-byte HashingAlgorithm.Code, 1-byte HashingAlgorithm.DigestSize followed by the Digest.

When an unknown hashing algorithm number is encountered a new HashingAlgorithm.Register is defined. This algorithm does not support matching nor computing a hash.

This behaviour allows parsing of any well formed MultiHash even when the hashing algorithm is unknown.

public MultiHash ( CodedInputStream stream ) : System
stream Google.Protobuf.CodedInputStream ( /// A containing the binary representation of the /// MultiHash. ///
Résultat System

MultiHash() public méthode

Creates a new instance of the MultiHash class from the specified Stream.
Reads the binary representation of MultiHash from the stream.

The binary representation is a 1-byte HashingAlgorithm.Code, 1-byte HashingAlgorithm.DigestSize followed by the Digest.

When an unknown hashing algorithm number is encountered a new HashingAlgorithm.Register is defined. This algorithm does not support matching nor computing a hash.

This behaviour allows parsing of any well formed MultiHash even when the hashing algorithm is unknown.

public MultiHash ( Stream stream ) : System
stream Stream ( /// A containing the binary representation of the /// MultiHash. ///
Résultat System

MultiHash() public méthode

Creates a new instance of the MultiHash class from the specified Base58 encoded string.
When an unknown hashing algorithm number is encountered a new HashingAlgorithm.Register is defined. This algorithm does not support matching nor computing a hash.

This behaviour allows parsing of any well formed MultiHash even when the hashing algorithm is unknown.

public MultiHash ( string s ) : System
s string /// A encoded MultiHash. ///
Résultat System

MultiHash() public méthode

Creates a new instance of the MultiHash class with the specified HashingAlgorithm">Algorithm name and
public MultiHash ( string algorithmName, byte digest ) : System
algorithmName string /// A valid IPFS hashing algorithm name, e.g. "sha2-256" or "sha2-512". ///
digest byte /// The digest value as a byte array. ///
Résultat System

RaiseUnknownHashingAlgorithm() public méthode

public RaiseUnknownHashingAlgorithm ( HashingAlgorithm algorithm ) : void
algorithm HashingAlgorithm
Résultat void

Read() public méthode

public Read ( CodedInputStream stream ) : void
stream Google.Protobuf.CodedInputStream
Résultat void

Read() public méthode

public Read ( Stream stream ) : void
stream Stream
Résultat void

ToArray() public méthode

Returns the IPFS binary representation as a byte array.
The binary representation is a sequence of MultiHash.
public ToArray ( ) : byte[]
Résultat byte[]

ToBase58() public méthode

Returns the Base58 encoding of the MultiHash.
public ToBase58 ( ) : string
Résultat string

ToString() public méthode

Returns the Base58 encoding of the MultiHash.
public ToString ( ) : string
Résultat string

Write() public méthode

Writes the binary representation to the specified CodedOutputStream.
The binary representation is a 1-byte HashingAlgorithm.Code, 1-byte HashingAlgorithm.DigestSize followed by the Digest.
public Write ( CodedOutputStream stream ) : void
stream Google.Protobuf.CodedOutputStream /// The to write to. ///
Résultat void

Write() public méthode

Writes the binary representation to the specified Stream.
The binary representation is a 1-byte HashingAlgorithm.Code, 1-byte HashingAlgorithm.DigestSize followed by the Digest.
public Write ( Stream stream ) : void
stream Stream /// The to write to. ///
Résultat void

Property Details

UnknownHashingAlgorithm public_oe static_oe property

Occurs when an unknown hashing algorithm number is parsed.
public static EventHandler UnknownHashingAlgorithm
Résultat EventHandler