RHash : RHash Namespace

Hasher Class

Incremental hasher.

Syntax

public sealed class Hasher

Remarks

This class allows you to do incremental hashing for set of hashing algorithms.

Requirements

Namespace: RHash
Assembly: RHash (in RHash.dll)
Assembly Versions: 1.0.1.1

Members

See Also: Inherited members from object.

Public Constructors

Creates new Hasher to compute message digest for given type.
Creates new Hasher to compute message digests for given set of hashing algorithms.

Public Methods

Finalize ()
Called by garbage collector to free native resources.
Finish ()
Finishes calculation of hashes.
static
GetHashForFile (string, HashType) : string
Computes message digest for given file.
static
GetHashForMsg (byte[], HashType) : string
Computes message digest for given binary message.
GetMagnet (string) : string
Generates magnet link with given filename.
GetMagnet (string, uint) : string
Generates magnet link with given filename and hashes.
static
GetMagnetFor (string, uint) : string
Generates magnet for specified file with given hashes.
Reset ()
Resets this Hasher to initial state.
ToBase32 (HashType) : string
Returns value of computed digest as base32 string.
ToBase64 (HashType) : string
Returns value of computed digest as base64 string.
ToHex (HashType) : string
Returns value of computed digest as hexadecimal string.
ToRaw (HashType) : string
Returns value of computed digest as raw bytes encoded in ANSI string.
override
ToString () : string
Returns value of computed digest as string in default format.
ToString (HashType) : string
Returns value of computed digest as string in default format.
Update (byte[]) : Hasher
Updates this Hasher with new data chunk.
Update (byte[], int) : Hasher
Updates this Hasher with new data chunk.
UpdateFile (string) : Hasher
Updates this Hasher with data from given file.

Member Details

Hasher Constructor

Creates new Hasher to compute message digest for given type.

Syntax

public Hasher (HashType hashtype)

Parameters

hashtype
Type of hashing algorithm.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: RHash
Assembly: RHash (in RHash.dll)
Assembly Versions: 1.0.1.1

Hasher Constructor

Creates new Hasher to compute message digests for given set of hashing algorithms.

Syntax

public Hasher (uint hashmask)

Parameters

hashmask
Mask created of one or more RHash.HashType values.

Exceptions

Type Reason
ArgumentException Argument is zero or contains invalid bits.

Remarks

Mask should be created from ORed HashType values. The next example will create Hasher that computes both CRC32 and MD5 sums:
C# Example
  new Hasher((uint)HashType.CRC32 | (uint)HashType.MD5);

Requirements

Namespace: RHash
Assembly: RHash (in RHash.dll)
Assembly Versions: 1.0.1.1

Finalize Method

Called by garbage collector to free native resources.

Syntax

void Finalize ()

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: RHash
Assembly: RHash (in RHash.dll)
Assembly Versions: 1.0.1.1

Finish Method

Finishes calculation of hashes.

Syntax

public void Finish ()

Remarks

Processes any buffered data and finishes computation of hash sums.

Requirements

Namespace: RHash
Assembly: RHash (in RHash.dll)
Assembly Versions: 1.0.1.1

GetHashForFile Method

Computes message digest for given file.

Syntax

public static string GetHashForFile (string filename, HashType type)

Parameters

filename
File to compute hash for.
type
Type of hash to compute.

Returns

Message digest as returned by Hasher.ToString(HashType).

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: RHash
Assembly: RHash (in RHash.dll)
Assembly Versions: 1.0.1.1

GetHashForMsg Method

Computes message digest for given binary message.

Syntax

public static string GetHashForMsg (byte[] buf, HashType type)

Parameters

buf
Binary message to compute hash for.
type
Type of hash to compute.

Returns

Message digest, as returned by Hasher.ToString(HashType).

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: RHash
Assembly: RHash (in RHash.dll)
Assembly Versions: 1.0.1.1

GetMagnet Method

Generates magnet link with given filename.

Syntax

public string GetMagnet (string filepath)

Parameters

filepath
File path to be included in magnet. May be null.

Returns

Magnet link.

Remarks

Magnet includes all hashes computed by this hasher. If filepath is null then returned magnet does not contain a filename.

Requirements

Namespace: RHash
Assembly: RHash (in RHash.dll)
Assembly Versions: 1.0.1.1

GetMagnet Method

Generates magnet link with given filename and hashes.

Syntax

public string GetMagnet (string filepath, uint hashmask)

Parameters

filepath
File path to be included in magnet. May be null.
hashmask
Mask created from one or more RHash.HashType values.

Returns

Magnet link.

Remarks

Only hashes that were computed by this Hasher are included in the output. If filepath is null then returned magnet does not contain a filename.

Requirements

Namespace: RHash
Assembly: RHash (in RHash.dll)
Assembly Versions: 1.0.1.1

GetMagnetFor Method

Generates magnet for specified file with given hashes.

Syntax

public static string GetMagnetFor (string filepath, uint hashmask)

Parameters

filepath
File to process.
hashmask
Mask created of one or more RHash.HashType values.

Returns

Magnet link.

Remarks

Returned magnet includes file name and all computed hashes.

Requirements

Namespace: RHash
Assembly: RHash (in RHash.dll)
Assembly Versions: 1.0.1.1

Reset Method

Resets this Hasher to initial state.

Syntax

public void Reset ()

Remarks

The Hasher becomes available to process new data chunks. Note, that this method returns Hasher to the state after creating the object, NOT the state when hashing continues. Therefore, all previously calculated hashes are lost and process starts from the very beginning.

Requirements

Namespace: RHash
Assembly: RHash (in RHash.dll)
Assembly Versions: 1.0.1.1

ToBase32 Method

Returns value of computed digest as base32 string.

Syntax

public string ToBase32 (HashType type)

Parameters

type
Type of hashing algorithm.

Returns

Message digest in form of base32 string.

Exceptions

Type Reason
ArgumentException This Hasher does not compute hash of given type.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: RHash
Assembly: RHash (in RHash.dll)
Assembly Versions: 1.0.1.1

ToBase64 Method

Returns value of computed digest as base64 string.

Syntax

public string ToBase64 (HashType type)

Parameters

type
Type of hashing algorithm.

Returns

Message digest in form of base64 string.

Exceptions

Type Reason
ArgumentException This Hasher does not compute hash of given type.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: RHash
Assembly: RHash (in RHash.dll)
Assembly Versions: 1.0.1.1

ToHex Method

Returns value of computed digest as hexadecimal string.

Syntax

public string ToHex (HashType type)

Parameters

type
Type of hashing algorithm.

Returns

Message digest in form of hexadecimal string.

Exceptions

Type Reason
ArgumentException This Hasher does not compute hash of given type.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: RHash
Assembly: RHash (in RHash.dll)
Assembly Versions: 1.0.1.1

ToRaw Method

Returns value of computed digest as raw bytes encoded in ANSI string.

Syntax

public string ToRaw (HashType type)

Parameters

type
Type of hashing algorithm.

Returns

Message digest as raw bytes encoded in an ANSI string.

Exceptions

Type Reason
ArgumentException This Hasher does not compute hash of given type.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: RHash
Assembly: RHash (in RHash.dll)
Assembly Versions: 1.0.1.1

ToString Method

Returns value of computed digest as string in default format.

Syntax

public override string ToString ()

Returns

Message digest as string.

Remarks

For Hasher created using Hasher(HashType) constructor, this method returns the same string as Hasher.ToString(HashType) method with the hash type used in constructor.

Requirements

Namespace: RHash
Assembly: RHash (in RHash.dll)
Assembly Versions: 1.0.1.1

ToString Method

Returns value of computed digest as string in default format.

Syntax

public string ToString (HashType type)

Parameters

type
Type of hashing algorithm.

Returns

Message digest for given hashing algorithm.

Exceptions

Type Reason
ArgumentException This Hasher does not compute hash of given type.

Remarks

If default output for hashing algorithm is base32 then returned value is the same as if Hasher.ToBase32(HashType) method was called; otherwise value is the same as returned by Hasher.ToHex(HashType) method.

Requirements

Namespace: RHash
Assembly: RHash (in RHash.dll)
Assembly Versions: 1.0.1.1

Update Method

Updates this Hasher with new data chunk.

Syntax

public Hasher Update (byte[] buf)

Parameters

buf
Data for hashing.

Returns

This hasher.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: RHash
Assembly: RHash (in RHash.dll)
Assembly Versions: 1.0.1.1

Update Method

Updates this Hasher with new data chunk.

Syntax

public Hasher Update (byte[] buf, int len)

Parameters

buf
Data for hashing.
len
Number of bytes in array to hash.

Returns

This Hasher.

Exceptions

Type Reason
IndexOutOfRangeException Argument len is negative or greater than buffer length.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: RHash
Assembly: RHash (in RHash.dll)
Assembly Versions: 1.0.1.1

UpdateFile Method

Updates this Hasher with data from given file.

Syntax

public Hasher UpdateFile (string filename)

Parameters

filename
Name of the file to process.

Returns

This Hasher.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: RHash
Assembly: RHash (in RHash.dll)
Assembly Versions: 1.0.1.1