3C科技 娛樂遊戲 美食旅遊 時尚美妝 親子育兒 生活休閒 金融理財 健康運動 寰宇綜合

Zi 字媒體

2017-07-25T20:27:27+00:00
加入好友
C# 檔案MD5計算   資料來源: http://www.dotblogs.com.tw/junegoat/archive/2012/08/21/c-sharp-md5-sha1-sha256-valid-file-correct.aspx Code using System; using System.Collections.Generic; using System.Linq; using System.Text; //http://www.dotblogs.com.tw/junegoat/archive/2012/08/21/c-sharp-md5-sha1-sha256-valid-file-correct.aspx namespace Console_CS_File_MD5 { class Program { static void Pause() { Console.Write("Press any key to continue . . . "); Console.ReadKey(true); } static void Main(string[] args) { var tragetFile = new System.IO.FileStream(@"C:\Users\RD\Desktop\Release\Ionic.Zip.dll", System.IO.FileMode.Open); var md5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); byte[] hashbytes = md5.ComputeHash(tragetFile); tragetFile.Close(); System.Text.StringBuilder sb = new System.Text.StringBuilder(); for (int i = 0; i < hashbytes.Length; i++) { sb.Append(hashbytes[i].ToString("x2")); } Console.WriteLine(sb.ToString()); Pause(); } } }

本文由jashliaoeuwordpress提供 原文連結

寫了 5860316篇文章,獲得 23313次喜歡
精彩推薦