コード例 #1
0
        public void ComputeAndVerifyHash_File()
        {
            var testFilePath = Path.GetTempFileName();
            var verifyResult = new GenericHashResult();
            var errorMessage = "";

            File.WriteAllText(testFilePath, _testString);

            var hashResult = _sha384.ComputeFileHash(testFilePath);

            if (hashResult.Success)
            {
                verifyResult = _sha384.VerifyFileHash(hashResult.HashString, testFilePath);

                if (!verifyResult.Success)
                {
                    errorMessage = verifyResult.Message;
                }
            }
            else
            {
                errorMessage = hashResult.Message;
            }

            Assert.IsTrue((hashResult.Success && verifyResult.Success), errorMessage);
        }