public SpookyHashV1_Implementation(ISpookyHashConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            _config = config.Clone();


            if (!_validHashSizes.Contains(_config.HashSizeInBits))
            {
                throw new ArgumentOutOfRangeException($"{nameof(config)}.{nameof(config.HashSizeInBits)}", _config.HashSizeInBits, $"{nameof(config)}.{nameof(config.HashSizeInBits)} must be contained within SpookyHashV1.ValidHashSizes.");
            }


            switch (_config.HashSizeInBits)
            {
            case 32:
                _seed1 = _config.Seed & 0xFFFFFFFF;
                _seed2 = _seed1;
                break;

            case 64:
                _seed1 = _config.Seed;
                _seed2 = _seed1;
                break;

            case 128:
                _seed1 = _config.Seed;
                _seed2 = _config.Seed2;
                break;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new <see cref="ISpookyHashV1"/> instance with the specified configuration.
        /// </summary>
        /// <param name="config">Configuration to use when constructing the instance.</param>
        /// <returns>A <see cref="ISpookyHashV1"/> instance.</returns>
        public ISpookyHashV1 Create(ISpookyHashConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            return(new SpookyHashV1_Implementation(config));
        }