zoukankan      html  css  js  c++  java
  • 获取文件hash值

     public string getFilesMD5Hash(string file)
            {
                //MD5 hash provider for computing the hash of the file
                MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();

                //open the file
                FileStream stream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read, 8192);

                //calculate the files hash
                md5.ComputeHash(stream);

                //close our stream
                stream.Close();

                //byte array of files hash
                byte[] hash = md5.Hash;

                //string builder to hold the results
                StringBuilder sb = new StringBuilder();

                //loop through each byte in the byte array
                foreach (byte b in hash)
                {
                    //format each byte into the proper value and append
                    //current value to return value
                    sb.Append(string.Format("{0:X2}", b));
                }

                //return the MD5 hash of the file
                return sb.ToString();
            }

  • 相关阅读:
    jquery封装的时间轴
    openlayers实现多图显示
    wms常用操作
    教你如何拔取百度地图POI兴趣点
    北京市地铁线路及站点数据
    Arcgis for js实现北京地铁的展示
    Openlayers 2.X加载高德地图
    Arcgis for js加载百度地图
    常用公共服务接口与java调用实现
    Openlayers 2.X加载天地图
  • 原文地址:https://www.cnblogs.com/CielWater/p/3757245.html
Copyright © 2011-2022 走看看