コード例 #1
0
 public static IBuzHash Create(BuzHashTypes type, BuzHashConfig config)
 {
     config.CheckNull(nameof(config));
     config = config.Clone();
     config.HashSizeInBits = (int)type;
     return(new BuzHashFunction(config));
 }
コード例 #2
0
        public BuzHashFunction(BuzHashConfig config)
        {
            if (config is null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            _config = config.Clone();

            if (_config.Rtab == null || _config.Rtab.Count != 256)
            {
                throw new ArgumentException($"{nameof(config.Rtab)} must be non-null list of 256 {nameof(UInt64)} values.", $"{nameof(config)}.{nameof(config.Rtab)}");
            }

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

            if (_config.ShiftDirection != CircularShiftDirection.Left && _config.ShiftDirection != CircularShiftDirection.Right)
            {
                throw new ArgumentOutOfRangeException($"{nameof(config)}.{nameof(config.ShiftDirection)}", _config.ShiftDirection, $"{nameof(config)}.{nameof(config.ShiftDirection)} must be a valid {nameof(CircularShiftDirection)} value.");
            }
        }
コード例 #3
0
 public static IBuzHash Create(BuzHashTypes type, BuzHashConfig config) => Factory.Create(type, config);