public bool?VerifyMediaImage() { byte[] calculated; if (mapVersion >= 3) { Sha1Context sha1Ctx = new Sha1Context(); for (uint i = 0; i < totalHunks; i++) { sha1Ctx.Update(GetHunk(i)); } calculated = sha1Ctx.Final(); } else { Md5Context md5Ctx = new Md5Context(); for (uint i = 0; i < totalHunks; i++) { md5Ctx.Update(GetHunk(i)); } calculated = md5Ctx.Final(); } return(expectedChecksum.SequenceEqual(calculated)); }
public void Md5EmptyInstance() { byte[] data = new byte[1048576]; FileStream fs = new FileStream(Path.Combine(Consts.TestFilesRoot, "checksums", "empty"), FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); fs.Dispose(); IChecksum ctx = new Md5Context(); ctx.Update(data); byte[] result = ctx.Final(); Assert.AreEqual(ExpectedEmpty, result); }
public void Md5RandomInstance() { byte[] data = new byte[1048576]; var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "random"), FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); fs.Dispose(); IChecksum ctx = new Md5Context(); ctx.Update(data); byte[] result = ctx.Final(); Assert.AreEqual(_expectedRandom, result); }
public void EmptyInstance() { byte[] data = new byte[1048576]; var fs = new FileStream(Path.Combine(Consts.TEST_FILES_ROOT, "Checksum test files", "empty"), FileMode.Open, FileAccess.Read); fs.Read(data, 0, 1048576); fs.Close(); fs.Dispose(); IChecksum ctx = new Md5Context(); ctx.Update(data); byte[] result = ctx.Final(); result.Should().BeEquivalentTo(_expectedEmpty); }