using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace ConsoleApplication6
{
public class Program
{
public static void Main(string[] args)
{
string fileName = @"D:\说明.txt";
string result = GetMD5HashFromFile(fileName);
} // <summary>
/// 计算文件的MD5校验
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
public static string GetMD5HashFromFile(string fileName)
{
try
{
FileStream file = new FileStream(fileName, FileMode.Open);
System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] retVal = md5.ComputeHash(file);
file.Close(); StringBuilder sb = new StringBuilder();
for (int i = ; i < retVal.Length; i++)
{
sb.Append(retVal[i].ToString("x2"));
}
return sb.ToString();
}
catch (Exception ex)
{
throw new Exception("GetMD5HashFromFile() fail,error:" + ex.Message);
}
}
}
}

最新文章

  1. 基于Vue2.0的单页面开发方案
  2. Swift开发小技巧--自定义转场动画
  3. POJ 1466 Girls and Boys 黑白染色 + 二分匹配 (最大独立集) 好题
  4. rhythmbox插件开发笔记1:简介&amp;入门
  5. 《OD学storm》20160827
  6. PHP - PDO 之 mysql 事务功能
  7. Meditation Guide
  8. c++重点知识点
  9. unity介绍
  10. JavaEE学习之设计模式
  11. 访问Access日期字段
  12. Luogu 2245 星际导航(最小生成树,最近公共祖先LCA,并查集)
  13. Android WebView 上传各种文件(包括拍照 录像 录音 文件 音乐 等,用到图片或拍照的,可以参考下)
  14. python爬虫(二)_HTTP的请求和响应
  15. Flutter 即学即用系列博客——04 Flutter UI 初窥
  16. 20145203盖泽双 《网络对抗技术》实践1—— MAL_逆向与Bof基础
  17. 安装ik分词器以及版本和ES版本的兼容性
  18. 异步图片下载引擎(升级版——ExecutorService+handler)
  19. CentOS 中 配置 Nginx 支持 https
  20. 启动hadoop 2.6遇到的datanode启动不了

热门文章

  1. UVALive 6859 Points (凸包)
  2. JavaSE知识点:finalize,treeMap
  3. (转)mnist.load_data()出现错误
  4. 【洛谷P1219 八皇后】
  5. shell 操作字符串 变量 数组
  6. 没看这篇干货,别和我说你会IDEA Debug
  7. 基于nginx实现二维码下载安装apk文件
  8. python nginx+uwsgi+WSGI 处理请求详解
  9. Common Linux Commands 日常工作常用Linux命令
  10. debian下重装mysql