コード例 #1
0
        public Pearson_Implementation(IPearsonConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            _config = config.Clone();


            if (_config.Table == null)
            {
                throw new ArgumentException($"{nameof(config)}.{nameof(config.Table)} must be non-null.", $"{nameof(config)}.{nameof(config.Table)}");
            }

            if (_config.Table.Count != 256 || _config.Table.Distinct().Count() != 256)
            {
                throw new ArgumentException($"{nameof(config)}.{nameof(config.Table)} must be a permutation of [0, 255].", $"{nameof(config)}.{nameof(config.Table)}");
            }


            if (_config.HashSizeInBits <= 0 || _config.HashSizeInBits % 8 != 0)
            {
                throw new ArgumentOutOfRangeException($"{nameof(config)}.{nameof(config.HashSizeInBits)}", _config.HashSizeInBits, $"{nameof(config)}.{nameof(config.HashSizeInBits)} must be a positive integer that is divisible by 8.");
            }
        }
コード例 #2
0
            public BlockTransformer(IPearsonConfig config)
                : this()
            {
                _table = config.Table;

                _anyBytesProcessed = false;
                _hashValue         = new byte[config.HashSizeInBits / 8];
            }
コード例 #3
0
        /// <summary>
        /// Creates a new <see cref="IPearson"/> instance with the specified configuration.
        /// </summary>
        /// <param name="config">Configuration to use when constructing the instance.</param>
        /// <returns>A <see cref="IPearson"/> instance.</returns>
        public IPearson Create(IPearsonConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            return(new Pearson_Implementation(config));
        }