/// <summary> /// Computes and checks MD5 digests in the given file. /// </summary> /// <param name="infile">the file to check</param> /// <param name="expected">the expected digest value</param> /// <param name="mode">the compute mode</param> /// <returns>true if the digests match, false otherwise</returns> public static bool Check(string infile, string expected, MD5SUMMODE mode) { string computed = Md5Sum.Compute(infile, mode); return (computed == expected); }
/// <summary> /// Computes the given file's MD5 digest. /// </summary> /// <param name="infile">the file to read</param> /// <param name="mode">the compute mode</param> /// <returns>a digest string for the given file</returns> public static string Compute(string infile, MD5SUMMODE mode) { if (mode != MD5SUMMODE.BINARY) throw new InvalidOperationException("md5sum mode is not supported!"); byte[] buf = File.ReadAllBytes(infile); return Md5Sum.Compute(buf); }