/// <summary> /// 计算文件大写40位SHA1值,用于文件唯一性校验 /// </summary> /// <param name="fileName">文件名</param> /// <returns>文件大写SHA1值</returns> public static string FileSHA1Compute(string fileName) { using (FileStream fs = new FileStream(fileName, FileMode.Open)) { SHA1CryptoServiceProvider sp = new SHA1CryptoServiceProvider(); byte[] result = sp.ComputeHash(fs); StringBuilder sb = new StringBuilder(); foreach (byte item in result) sb.AppendFormat("{0:X2}", item); return sb.ToString(); } }