57 catch 58 { 59 60 return false; 61 62 } 63 } 64 private static string MD5Buffer(byte[] pdfFile, int index, int count) 65 { 66 System.Security.Cryptography.MD5CryptoServiceProvider get_md5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); 67 byte[] hash_byte = get_md5.ComputeHash(pdfFile, index, count); 68 69 string result = System.BitConverter.ToString(hash_byte); 70 result = result.Replace("-", ""); 71 return result; 72 } 73 private static string MD5String(string str) 74 { 75 byte[] MD5Source = System.Text.Encoding.ASCII.GetBytes(str); 76 return MD5Buffer(MD5Source, 0, MD5Source.Length); 77 78 } 79 } 以上代码不仅仅只适用于PDF文件,对于其他一些格式也可以用,这主要是取决于文件的格式规范 |