Librhash is a library for computing and verifying hash sums that supports many hashing algorithms. This module provides class for incremental hashing that utilizes the library. Sample usage of it you can see from the following example:
C# Example |
Hasher hasher = new Hasher((uint)HashType.CRC32 | (uint)HashType.MD5); hasher.Update(bytebuffer).UpdateFile("SomeFile.txt"); hasher.Finish(); Console.WriteLine(hasher.ToHex(HashType.CRC32)); Console.WriteLine(hasher.ToBase32(HashType.MD5)); |
In this example RHash.Hasher object is first created for a set of hashing algorithms.
Next, data for hashing is given in chunks with methods Update() and UpdateFile(). Finally, call Finish() to end up all remaining calculations.
To receive text represenation of the message digest use one of methods ToHex(), ToBase32() and ToBase64(). Binary message digest may be obtained with ToRaw(). All of these methods accept algorithm value as argument. It may be omitted if Hasher was created to compute hash for only a single hashing algorithm.
Type | Description |
---|---|
Hasher | Incremental hasher. |
HashType | Type of hashing algorithm. |