/// <summary>Initializes a new instance of the FNV class.</summary> /// <param name="parameters">The parameters to utilize in the FNV calculation.</param> /// <exception cref="ArgumentNullException">When the specified parameters are null.</exception> public Fnv(FnvParameters parameters) : base() { lock (syncLock) { if (parameters == null) { throw new ArgumentNullException("parameters", Hasher.Properties.Resources.paramCantBeNull); } this.parameters = parameters; HashSizeValue = this.parameters.Order; hash = (ulong)this.parameters.OffsetBasis; } }
/// <summary>Retrieves a standard set of FNV parameters.</summary> /// <param name="standard">The name of the standard parameter set to retrieve.</param> /// <returns>The FNV Parameters for the given standard.</returns> public static FnvParameters GetParameters(FnvStandard standard) { FnvParameters temp = null; switch (standard) { case FnvStandard.Fnv32BitType0: temp = new FnvParameters(32, 0x01000193, 0x00000000, FnvAlgorithmType.Fnv1); break; case FnvStandard.Fnv64BitType0: temp = new FnvParameters(64, 0x0100000001B3, 0x00000000, FnvAlgorithmType.Fnv1); break; case FnvStandard.Fnv32BitType1: temp = new FnvParameters(32, 0x01000193, 0x811C9DC5, FnvAlgorithmType.Fnv1); break; case FnvStandard.Fnv64BitType1: temp = new FnvParameters(64, 0x0100000001B3, unchecked ((long)0xCBF29CE484222325), FnvAlgorithmType.Fnv1); break; case FnvStandard.Fnv32BitType1A: temp = new FnvParameters(32, 0x01000193, 0x811C9DC5, FnvAlgorithmType.Fnv1A); break; case FnvStandard.Fnv64BitType1A: temp = new FnvParameters(64, 0x0100000001B3, unchecked ((long)0xCBF29CE484222325), FnvAlgorithmType.Fnv1A); break; } return(temp); }
/// <summary>Initializes a new instance of the FNV class.</summary> /// <remarks>This constructor implements the default parameters of Fnv32BitType1A.</remarks> public Fnv() : this(FnvParameters.GetParameters(FnvStandard.Fnv32BitType1A)) { }