Exemple #1
0
        protected Fnv1Base(FnvConfig config)
        {
            if (config is 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);
        }
Exemple #2
0
 public static IFNV Create(FnvTypes type, FnvConfig config) => Factory.Create(type, config);
Exemple #3
0
 public Fnv1AFunction(FnvConfig config) : base(config)
 {
 }