/// <summary> /// Creates a new <see cref="IHashAlgorithmWrapper"/> instance with given configuration. /// </summary> /// <param name="config">The configuration to use.</param> /// <returns>A <see cref="IHashAlgorithmWrapper"/> instance.</returns> public IHashAlgorithmWrapper Create(IHashAlgorithmWrapperConfig config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } return(new HashAlgorithmWrapper_Implementation(config)); }
/// <summary> /// Initializes a new instance of the <see cref="HashAlgorithmWrapper_Implementation"/> class. /// </summary> /// <param name="config">The configuration to use for this instance.</param> /// <exception cref="ArgumentNullException"><paramref name="config"/></exception> /// <exception cref="ArgumentException"><paramref name="config"/>.<see cref="IHashAlgorithmWrapperConfig.InstanceFactory"/> has not been set.;<paramref name="config"/>.<see cref="IHashAlgorithmWrapperConfig.InstanceFactory"/></exception> public HashAlgorithmWrapper_Implementation(IHashAlgorithmWrapperConfig config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } _config = config.Clone(); if (_config.InstanceFactory == null) { throw new ArgumentException($"{nameof(config)}.{nameof(config.InstanceFactory)} has not been set.", $"{nameof(config)}.{nameof(config.InstanceFactory)}"); } using (var hashAlgorithm = _config.InstanceFactory()) HashSizeInBits = hashAlgorithm.HashSize; }