当前位置: 首页>>代码示例>>C#>>正文


C# SHA256Managed.IsEqualTo方法代码示例

本文整理汇总了C#中System.Security.Cryptography.SHA256Managed.IsEqualTo方法的典型用法代码示例。如果您正苦于以下问题:C# SHA256Managed.IsEqualTo方法的具体用法?C# SHA256Managed.IsEqualTo怎么用?C# SHA256Managed.IsEqualTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Security.Cryptography.SHA256Managed的用法示例。


在下文中一共展示了SHA256Managed.IsEqualTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Dev_Signed_XVC_Decrypt_Test

        public void Dev_Signed_XVC_Decrypt_Test()
        {
            const string dest = @"F:\XBone\XVDs\TestXVDs\xvd1_decrypted_temp";
            const string fileToCompare = @"F:\XBone\XVDs\TestXVDs\xvd1_decrypted";
            if (File.Exists(dest))
                File.Delete(dest);

            File.Copy(@"F:\XBone\XVDs\TestXVDs\xvd1", dest);
            using (var file = new XvdFile(dest))
            {
                Assert.IsTrue(file.Load());
                Assert.IsTrue(file.Header.IsSignedWithRedKey);
                Assert.IsTrue(file.IsEncrypted);
                Assert.IsTrue(file.IsDataIntegrityEnabled);
                Assert.IsTrue(file.HashTreeValid);
                Assert.IsTrue(file.DataHashTreeValid);
                Assert.IsTrue(file.Decrypt());
                Assert.IsFalse(file.IsEncrypted);
                int[] invalid = file.VerifyDataHashTree();
                Assert.IsTrue(invalid.Length == 0);
                Assert.IsTrue(file.VerifyHashTree());

                byte[] ntfsString = file.Read(0x87003, 4);
                byte[] expectedString = { 0x4E, 0x54, 0x46, 0x53 };
                Assert.IsTrue(ntfsString.IsEqualTo(expectedString));
            }

            byte[] generatedHash;
            using (FileStream stream = File.OpenRead(dest))
            {
                generatedHash = new SHA256Managed().ComputeHash(stream);
            }

            File.Delete(dest);

            byte[] expectedHash;
            using (FileStream stream = File.OpenRead(fileToCompare))
            {
                expectedHash = new SHA256Managed().ComputeHash(stream);
            }

            Assert.IsTrue(generatedHash.IsEqualTo(expectedHash));
        }
开发者ID:Overx,项目名称:xvdtool,代码行数:43,代码来源:XvdFileTests.cs

示例2: Unsigned_XVD_Encrypt_Test

        public void Unsigned_XVD_Encrypt_Test()
        {
            const string dest = @"F:\XBone\XVDs\TestXVDs\xvd2_encrypted_temp";
            const string fileToCompare = @"F:\XBone\XVDs\TestXVDs\xvd2";
            if (File.Exists(dest))
                File.Delete(dest);

            File.Copy(@"F:\XBone\XVDs\TestXVDs\xvd2_decrypted_orig_mod", dest); // modded with CIK used in xvd2
            using (var file = new XvdFile(dest))
            {
                Assert.IsTrue(file.Load());
                Assert.IsFalse(file.Header.IsSignedWithRedKey);
                Assert.IsFalse(file.IsEncrypted);
                Assert.IsFalse(file.IsDataIntegrityEnabled);
                Assert.IsTrue(file.Encrypt());
                Assert.IsTrue(file.IsEncrypted);

                // copy values from file being compared so the hashes match
                file.Header.PDUID = new byte[] {0xEA, 0xC8, 0xE2, 0x82, 0x2F, 0x58, 0x32, 0x4F, 0x92, 0x29, 0xE1, 0xAB, 0x6E, 0x8F, 0x91, 0x63};
                using (FileStream stream = File.OpenRead(fileToCompare))
                {
                    stream.Position = 0;
                    stream.Read(file.Header.Signature, 0, 0x200);
                }

                Assert.IsTrue(file.AddHashTree());

                int[] invalid = file.VerifyDataHashTree();
                Assert.IsTrue(invalid.Length == 0);
                Assert.IsTrue(file.VerifyHashTree());
            }

            byte[] generatedHash;
            using (FileStream stream = File.OpenRead(dest))
            {
                generatedHash = new SHA256Managed().ComputeHash(stream);
            }

            File.Delete(dest);

            byte[] expectedHash;
            using (FileStream stream = File.OpenRead(fileToCompare))
            {
                expectedHash = new SHA256Managed().ComputeHash(stream);
            }

            Assert.IsTrue(generatedHash.IsEqualTo(expectedHash));
        }
开发者ID:Overx,项目名称:xvdtool,代码行数:48,代码来源:XvdFileTests.cs


注:本文中的System.Security.Cryptography.SHA256Managed.IsEqualTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。