Table of Contents

Class FowlerNollVo32

Namespace
Cuemon.Security
Assembly
Cuemon.Core.dll

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 class.

using System;
using System.Text;
using Cuemon; // for Endianness
using Cuemon.Security; // for FowlerNollVo32

using Cuemon;
namespace MyApp.Examples;

public class FowlerNollVo32Example
{
    public void Demonstrate()
    {
        var fnv = new FowlerNollVo32();

        // Compute hash of a string
        byte[] data = Encoding.UTF8.GetBytes("hello");
        var hash = fnv.ComputeHash(data);

        Console.WriteLine(hash.ToHexadecimalString()); // F970D0C7 (big-endian default)
        Console.WriteLine(hash.ToBase64String());      // +XDQxw==
        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)); // C7-D0-70-F9

        // Use FNV-1 variant instead of FNV-1a
        fnv.Options.Algorithm = FowlerNollVoAlgorithm.Fnv1;
        hash = fnv.ComputeHash(data);
        Console.WriteLine(hash.ToHexadecimalString()); // E973FD3B

}
}

Constructors

FowlerNollVo32(Action<FowlerNollVoOptions>)

Initializes a new instance of the FowlerNollVo32 class.

public FowlerNollVo32(Action<FowlerNollVoOptions> setup = null)

Parameters

setup Action<FowlerNollVoOptions>

The FowlerNollVoOptions which may be configured.

See Also