FowlerNollVo32 Class
Definition
Provides an implementation of the FVN (Fowler–Noll–Vo) non-cryptographic hashing algorithm for 32-bit hash values. This class cannot be inherited. Implements the FowlerNollVoHash
public sealed class FowlerNollVo32 : FowlerNollVoHash, IHash, IConfigurable<FowlerNollVoOptions>
- Inheritance
-
FowlerNollVo32
- Implements
- Inherited Members
Examples
The following example demonstrates how to compute a 32-bit FNV-1a hash using the
// Program.cs
using System;
using System.Text;
using Cuemon; // for Endianness
using Cuemon.Security; // for FowlerNollVo32
var fnv = new FowlerNollVo32();
// Compute hash of a string
byte[] data = Encoding.UTF8.GetBytes("hello");
var hash = fnv.ComputeHash(data);
Console.WriteLine(hash.ToHexadecimalString()); // 4f9f2cab (big-endian default)
Console.WriteLine(hash.ToBase64String()); // T58sqw==
Console.WriteLine(fnv.Bits); // 32
// Configure for little-endian output
var fnvLe = new FowlerNollVo32(o => o.ByteOrder = Endianness.LittleEndian);
byte[] hashBytes = fnvLe.ComputeHash(data).GetBytes();
Console.WriteLine(BitConverter.ToString(hashBytes)); // AB-2C-9F-4F
// Use FNV-1 variant instead of FNV-1a
fnv.Options.Algorithm = FowlerNollVoAlgorithm.Fnv1;
hash = fnv.ComputeHash(data);
Console.WriteLine(hash.ToHexadecimalString()); // b6fa7167
Constructors
| Name | Description |
|---|---|
| FowlerNollVo32(Action<FowlerNollVoOptions>) | Initializes a new instance of the FowlerNollVo32 class. |