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();         }

  • 相关阅读:
    zuanwenzhang
    win32 打印机api
    错误码linux
    sed的一个知识点
    linux 修改时区
    赵鹏雁?、、
    Linux下模块编译错误
    Android加速度传感器实现“摇一摇”,带手机振动 .
    Android百度地图基础实现(标记+GPS) .
    Android 中 getApplicationContext()、this、getApplication()之间的区别 .
  • 原文地址:https://www.cnblogs.com/yudishow/p/4238006.html
Copyright © 2011-2022 走看看