Exemplo n.º 1
0
        private void VerifyICryptoTransformStream(Stream input, string output)
        {
            byte[] expected = ByteUtils.HexToByteArray(output);
            byte[] actual;

            using (HashAlgorithm hash = Create())
                using (CryptoStream cryptoStream = new CryptoStream(input, hash, CryptoStreamMode.Read))
                {
                    byte[] buffer = new byte[1024]; // A different default than HashAlgorithm which uses 4K
                    int    bytesRead;
                    while ((bytesRead = cryptoStream.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        // CryptoStream will build up the hash
                    }

                    actual = hash.Hash;
                }

            Assert.Equal(expected, actual);
        }
Exemplo n.º 2
0
 public DataRepeatingStream(string data, int repeatCount)
 {
     _remaining = repeatCount;
     _data      = ByteUtils.AsciiBytes(data);
 }
Exemplo n.º 3
0
 protected void Verify(string input, string output)
 {
     Verify(ByteUtils.AsciiBytes(input), output);
 }