コード例 #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);
        }
コード例 #2
0
            public BlockTransformer_ExtendedBase(FnvPrimeOffset fnvPrimeOffset) : this()
            {
                _prime = fnvPrimeOffset.Prime.ToArray();

                _hashValue       = fnvPrimeOffset.Offset.ToArray();
                _hashSizeInBytes = _hashValue.Length * 4;
            }
コード例 #3
0
            public BlockTransformer_64BitBase(FnvPrimeOffset fnvPrimeOffset) : this()
            {
                _prime = ((UInt64)fnvPrimeOffset.Prime[1] << 32) | fnvPrimeOffset.Prime[0];

                _hashValue = ((UInt64)fnvPrimeOffset.Offset[1] << 32) | fnvPrimeOffset.Offset[0];
            }
コード例 #4
0
            public BlockTransformer_32BitBase(FnvPrimeOffset fnvPrimeOffset) : this()
            {
                _prime = fnvPrimeOffset.Prime[0];

                _hashValue = fnvPrimeOffset.Offset[0];
            }