Beispiel #1
0
        private static List <IEntropyHasher> GetAllEntropyHashers()
        {
            var hashers = new List <IEntropyHasher>();

            // Add the .NET implementation of SHA256 and RNGCryptoServiceProvider
            {
                var rng         = new SystemRng();
                var hashWrapper = new HashAlgorithmWrapper(SHA256.Create());
                hashers.Add(new EntropyHasher(rng, hashWrapper));
            }

            // Add the ThreadedSeedGeneratorRNG as entropy source, and chain SHA256 and RipeMD256 as hash algorithms
            {
                var rng          = new ThreadedSeedGeneratorRng();
                var hashWrappers = new List <IHashAlgorithmWrapper>
                {
                    new HashAlgorithmWrapper(SHA256.Create()),
                    new HashAlgorithmWrapper(new RipeMD256Digest())
                };
                hashers.Add(new EntropyHasher(rng, hashWrappers));
            }

            // Add the ThreadSchedulerRNG as entropy source, and SHA256 as hash algorithm
            {
                var rng         = new ThreadSchedulerRng();
                var hashWrapper = new HashAlgorithmWrapper(new Sha256Digest());
                hashers.Add(new EntropyHasher(rng, hashWrapper));
            }
            return(hashers);
        }
Beispiel #2
0
 public EntropyHasher(RandomNumberGenerator rng, HashAlgorithmWrapper hashWrapper)
 {
     if (rng == null)
     {
         throw new ArgumentNullException(nameof(rng));
     }
     if (hashWrapper == null)
     {
         throw new ArgumentNullException(nameof(hashWrapper));
     }
     this.Rng          = rng;
     this.HashWrappers = new List <IHashAlgorithmWrapper> {
         hashWrapper
     };
 }