public void VerifyNullArray2() { Md5Sum sum = new Md5Sum(); Assert.IsNotNull(sum); bool match = sum.Verify(new byte[1], (byte[])null); }
public void CalculateBytesFromNull() { Md5Sum sum = new Md5Sum(); Assert.IsNotNull(sum); byte[] check = sum.Calculate((byte[])null); }
public void VerifyFromTestFile1() { Md5Sum sum = new Md5Sum(); Assert.IsNotNull(sum); byte[] array = File.ReadAllBytes("../../TestData/TextFile1.txt"); bool match = sum.Verify(array, File1Sum); Assert.IsTrue(match); }
public void CalculateBytesFromEmpty() { Md5Sum sum = new Md5Sum(); Assert.IsNotNull(sum); byte[] data = new byte[0]; byte[] check = sum.Calculate(data); Assert.IsNotNull(check); Assert.AreEqual(16, check.Length); }
public void VerifyFromTestFile1Stream() { Md5Sum sum = new Md5Sum(); Assert.IsNotNull(sum); FileStream file = new FileStream("../../TestData/TextFile1.txt", FileMode.Open); bool match = sum.Verify(file, File1Sum); file.Close(); Assert.IsTrue(match); }
public void VerifyFromTestFile1Fail() { Md5Sum sum = new Md5Sum(); Assert.IsNotNull(sum); // Create invalid checksum byte[] invalidSum = new byte[16]; Array.Copy(File1Sum, invalidSum, 16); invalidSum[3] = 0x00; byte[] array = File.ReadAllBytes("../../TestData/TextFile1.txt"); bool match = sum.Verify(array, invalidSum); Assert.IsFalse(match); }
public void VerifyFromTestFile1StreamFail() { Md5Sum sum = new Md5Sum(); Assert.IsNotNull(sum); // Create invalid checksum byte[] invalidSum = new byte[16]; Array.Copy(File1Sum, invalidSum, 16); invalidSum[3] = 0x00; FileStream file = new FileStream("../../TestData/TextFile1.txt", FileMode.Open); bool match = sum.Verify(file, invalidSum); file.Close(); Assert.IsFalse(match); }
public void CalculateFromTestFile1() { Md5Sum sum = new Md5Sum(); Assert.IsNotNull(sum); byte[] array = File.ReadAllBytes("../../TestData/TextFile1.txt"); byte[] check = sum.Calculate(array); Assert.IsNotNull(check); Assert.AreEqual(16, check.Length); for (int i = 0; i < File1Sum.Length; i++) { if (check[i] != File1Sum[i]) { Assert.Fail("Result byte {0} does not match! Was {1}, expected {2}", i, check[i], File1Sum[i]); } } }
public void CalculateFromTestFile1Stream() { Md5Sum sum = new Md5Sum(); Assert.IsNotNull(sum); FileStream file = new FileStream("../../TestData/TextFile1.txt", FileMode.Open); byte[] check = sum.Calculate(file); file.Close(); Assert.IsNotNull(check); Assert.AreEqual(16, check.Length); for (int i = 0; i < File1Sum.Length; i++) { if (check[i] != File1Sum[i]) { Assert.Fail("Result byte {0} does not match! Was {1}, expected {2}", i, check[i], File1Sum[i]); } } }
/// <summary> /// Get checksum calculator for given checksum type. /// </summary> /// <param name="impl">Checksum type.</param> /// <returns>Checksum calculator.</returns> public static ICheckSum GetImplementation(CheckSumType impl) { ICheckSum sum; switch (impl) { case CheckSumType.SHA1: sum = new Sha1Sum(); break; case CheckSumType.MD5: sum = new Md5Sum(); break; case CheckSumType.CRC32: sum = new CRC32Sum(); break; case CheckSumType.CRC64_ECMA: sum = new CRC64ECMASum(); break; case CheckSumType.CRC64_ISO: sum = new CRC64ISOSum(); break; default: sum = new Sha1Sum(); #if DEBUG throw new ApplicationException("Unknown Sum type!"); #else break; #endif } return(sum); }
/// <summary> /// Get checksum calculator for given checksum type. /// </summary> /// <param name="impl">Checksum type.</param> /// <returns>Checksum calculator.</returns> public static ICheckSum GetImplementation(CheckSumType impl) { ICheckSum sum; switch (impl) { case CheckSumType.SHA1: sum = new Sha1Sum(); break; case CheckSumType.MD5: sum = new Md5Sum(); break; case CheckSumType.CRC32: sum = new CRC32Sum(); break; default: sum = new Sha1Sum(); #if DEBUG throw new ApplicationException("Unknown Sum type!"); #else break; #endif } return sum; }
public void Create() { Md5Sum sum = new Md5Sum(); Assert.IsNotNull(sum); }