Example #1
0
        protected void VerifyMultiBlock(string block1, string block2, string expectedHash, string emptyHash)
        {
            byte[] block1_bytes    = ByteUtils.AsciiBytes(block1);
            byte[] block2_bytes    = ByteUtils.AsciiBytes(block2);
            byte[] expected_bytes  = ByteUtils.HexToByteArray(expectedHash);
            byte[] emptyHash_bytes = ByteUtils.HexToByteArray(emptyHash);

            VerifyTransformBlockOutput(block1_bytes, block2_bytes);
            VerifyTransformBlockHash(block1_bytes, block2_bytes, expected_bytes, emptyHash_bytes);
            VerifyTransformBlockComputeHashInteraction(block1_bytes, block2_bytes, expected_bytes, emptyHash_bytes);
        }
        private void Verify(string rawText, string expected)
        {
            byte[] inputBytes    = ByteUtils.AsciiBytes(rawText);
            byte[] expectedBytes = ByteUtils.HexToByteArray(expected);

            using (var hash = new SHA1CryptoServiceProvider())
            {
                Assert.True(hash.HashSize > 0);
                byte[] actual = hash.ComputeHash(inputBytes, 0, inputBytes.Length);

                Assert.Equal(expectedBytes, actual);

                actual = hash.Hash;
                Assert.Equal(expectedBytes, actual);
            }
        }
        private void Verify <T>(string rawText, string expected) where T : HashAlgorithm, new()
        {
            byte[] inputBytes    = ByteUtils.AsciiBytes(rawText);
            byte[] expectedBytes = ByteUtils.HexToByteArray(expected);

            using (HashAlgorithm hash = new T())
            {
                Assert.True(hash.HashSize > 0);
                byte[] actual = hash.ComputeHash(inputBytes, 0, inputBytes.Length);

                Assert.Equal(expectedBytes, actual);

                actual = hash.Hash;
                Assert.Equal(expectedBytes, actual);
            }
        }
Example #4
0
 protected void Verify(string input, string output)
 {
     Verify(ByteUtils.AsciiBytes(input), output);
 }
Example #5
0
 public DataRepeatingStream(string data, int repeatCount)
 {
     _remaining = repeatCount;
     _data      = ByteUtils.AsciiBytes(data);
 }