Exemple #1
0
 /// <summary>
 /// Initializes the <see cref="CrossPlatformEncryptor"/> given the <see cref="AdvancedSecureRandom"/> instance to use for our encryption.
 /// </summary>
 /// <param name="secureRandom"> The <see cref="AdvancedSecureRandom"/> instance to use for our encryption. </param>
 protected CrossPlatformEncryptor(AdvancedSecureRandom secureRandom) : this(
         secureRandom.NextBytes(2),
         secureRandom.NextBytes(4),
         secureRandom.NextBytes(8),
         secureRandom.NextBytes(16),
         secureRandom.NextBytes(32),
         secureRandom.NextBytes(64),
         secureRandom.NextBytes(128),
         secureRandom.NextBytes(256))
 {
 }
        public void CorrectSeededByteGeneration()
        {
            AdvancedSecureRandom secureRandom  = new AdvancedSecureRandom("test seed", 312);
            AdvancedSecureRandom secureRandom2 = new AdvancedSecureRandom("test seed", 312);

            const int size = 32;

            byte[] randomBytes  = secureRandom.NextBytes(size);
            byte[] randomBytes2 = secureRandom2.NextBytes(size);

            for (int i = 0; i < size; i++)
            {
                Assert.AreEqual(randomBytes[i], randomBytes2[i]);
            }
        }