Example #1
0
        private void VerifyHashInfo(string expectedAlgorithm, byte[] expectedHash, string expectedHashString, string expectedPath, HashInfo actualHashInfo)
        {
            Assert.AreEqual(expectedAlgorithm, actualHashInfo.Algorithm);
            StringAssert.AreEqualIgnoringCase(expectedPath, actualHashInfo.Path);
            StringAssert.AreEqualIgnoringCase(expectedHashString, actualHashInfo.HashString);

            Assert.AreEqual(expectedHash.Length, actualHashInfo.Hash.Length);
            for (int i = 0; i < expectedHash.Length; i++)
            {
                Assert.AreEqual(expectedHash[i], actualHashInfo.Hash[i]);
            }
        }
Example #2
0
        private void WriteHash(byte[] hash, string path)
        {
            StringBuilder strBld = new StringBuilder();
            foreach (byte b in hash)
            {
                strBld.AppendFormat("{0:X2}", b);
            }

            HashInfo hashInfo = new HashInfo(path, _algorithm.ToUpperInvariant(), strBld.ToString(), hash);
            WriteObject(hashInfo);
        }