protected FNV1Base(IFNVConfig config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } _config = config.Clone(); if (_config.HashSizeInBits <= 0 || _config.HashSizeInBits % 32 != 0) { throw new ArgumentOutOfRangeException($"{nameof(config)}.{nameof(config.HashSizeInBits)}", _config.HashSizeInBits, $"{nameof(config)}.{nameof(config.HashSizeInBits)} must be a positive a multiple of 32."); } if (_config.Prime <= BigInteger.Zero) { throw new ArgumentOutOfRangeException($"{nameof(config)}.{nameof(config.Prime)}", _config.Prime, $"{nameof(config)}.{nameof(config.Prime)} must be greater than zero."); } if (_config.Offset <= BigInteger.Zero) { throw new ArgumentOutOfRangeException($"{nameof(config)}.{nameof(config.Offset)}", _config.Offset, $"{nameof(config)}.{nameof(config.Offset)} must be greater than zero."); } _fnvPrimeOffset = FNVPrimeOffset.Create(_config.HashSizeInBits, _config.Prime, _config.Offset); }
/// <summary> /// Creates a new <see cref="IFNV1"/> instance with the specified configuration. /// </summary> /// <param name="config">Configuration to use when constructing the instance.</param> /// <returns>A <see cref="IFNV1"/> instance.</returns> public IFNV1 Create(IFNVConfig config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } return(new FNV1_Implementation(config)); }
private FNV1Impl(IFNVConfig config) : base(config) { }
/// <summary> /// Initializes a new instance of the <see cref="FNV1_Implementation"/> class. /// </summary> /// <inheritdoc cref="FNV1Base(IFNVConfig)" /> public FNV1_Implementation(IFNVConfig config) : base(config) { }