資源簡介
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace MD5校正工具 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void btnOpenFile_Click(object sender, EventArgs e) { using (OpenFileDialog dialog = new OpenFileDialog()) { if (dialog.ShowDialog() == DialogResult.OK) { String fileName = dialog.FileName; this.txtMD5.Text = ""; //this.txtSH1.Text = ""; // this.txtMD5.Text = getMD5Hash(fileName); //this.txtSH1.Text = GetMD5Hash(fileName); } } } //計算文件的MD5碼 private string getMD5Hash(string pathName) { string strResult = ""; string strHashData = ""; byte[] arrbytHashValue; System.IO.FileStream oFileStream = null; System.Security.Cryptography.MD5CryptoServiceProvider oMD5Hasher = new System.Security.Cryptography.MD5CryptoServiceProvider(); try { oFileStream = new System.IO.FileStream(pathName, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite) ; arrbytHashValue = oMD5Hasher.ComputeHash(oFileStream);//計算指定Stream 對象的哈希值 oFileStream.Close(); //由以連字符分隔的十六進制對構成的String,其中每一對表示value 中對應的元素;例如“F-2C-4A” strHashData = System.BitConverter.ToString(arrbytHashValue); //替換- strHashData = strHashData.Replace("-", ""); strResult = strHashData; } catch (System.Exception ex) { MessageBox.Show(ex.Message); } return strResult; } } }
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
namespace?MD5校正工具
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?btnOpenFile_Click(object?sender?EventArgs?e)
????????{
????????????using?(OpenFileDialog?dialog?=?new?OpenFileDialog())
????????????{
????????????????if?(dialog.ShowDialog()?==?DialogResult.OK)
????????????????{
????????????????????String?fileName?=?dialog.FileName;
????????????????????this.txtMD5.Text?=?““;
????????????????????//this.txtSH1.Text?=?““;
????????????????????//
????????????????????this.txtMD5.Text?=?getMD5Hash(fileName);
????????????????????//this.txtSH1.Text?=?GetMD5Hash(fileName);
????????????????}
????????????}
????????}
????????//計算文件的MD5碼
????????private?string?getMD
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????5612??2014-01-19?19:41??MD5校正工具\Properties\Resources.resx
?????文件????????249??2014-01-19?19:41??MD5校正工具\Properties\Settings.settings
?????文件???????1380??2014-01-19?19:41??MD5校正工具\Properties\AssemblyInfo.cs
?????文件???????2869??2014-05-02?11:28??MD5校正工具\Properties\Resources.Designer.cs
?????文件???????1114??2014-05-02?11:28??MD5校正工具\Properties\Settings.Designer.cs
?????文件???????4095??2014-05-02?11:28??MD5校正工具\MD5校正工具.csproj
?????文件????????180??2014-01-19?19:49??MD5校正工具\obj\Debug\MD5校正工具.Form1.resources
?????文件????????180??2014-01-19?19:44??MD5校正工具\obj\Debug\MD5校正工具.Properties.Resources.resources
?????文件????????732??2014-01-19?19:50??MD5校正工具\obj\Debug\MD5校正工具.csproj.FileListAbsolute.txt
?????文件??????24064??2014-01-19?20:21??MD5校正工具\obj\Debug\MD5校正工具.pdb
?????文件???????9216??2014-01-19?20:21??MD5校正工具\obj\Debug\MD5校正工具.exe
?????文件????????847??2014-01-19?19:49??MD5校正工具\obj\Debug\MD5校正工具.csproj.GenerateResource.Cache
?????文件???????4608??2014-05-02?11:28??MD5校正工具\obj\Release\TempPE\Properties.Resources.Designer.cs.dll
?????文件????????180??2014-05-02?11:28??MD5校正工具\obj\Release\MD5校正工具.Form1.resources
?????文件????????180??2014-05-02?11:28??MD5校正工具\obj\Release\MD5校正工具.Properties.Resources.resources
?????文件??????28160??2014-05-02?11:28??MD5校正工具\obj\Release\MD5校正工具.pdb
?????文件???????9216??2014-05-02?11:28??MD5校正工具\obj\Release\MD5校正工具.exe
?????文件???????1463??2014-05-02?11:28??MD5校正工具\obj\Release\MD5校正工具.csproj.FileListAbsolute.txt
?????文件????????847??2014-01-19?20:28??MD5校正工具\obj\Release\MD5校正工具.csproj.GenerateResource.Cache
?????文件???????6149??2014-05-02?11:28??MD5校正工具\obj\Release\DesignTimeResolveAssemblyReferencesInput.cache
?????文件????????496??2014-01-19?19:41??MD5校正工具\Program.cs
?????文件???????5814??2014-01-19?19:49??MD5校正工具\Form1.resx
?????文件???????2774??2014-01-19?20:28??MD5校正工具\Form1.Designer.cs
?????文件???????2347??2014-01-19?19:49??MD5校正工具\Form1.cs
?????文件????????935??2014-05-02?11:28??MD5校正工具.sln
?????目錄??????????0??2014-01-19?19:41??MD5校正工具\obj\Debug\TempPE
?????目錄??????????0??2014-01-19?20:26??MD5校正工具\obj\Release\TempPE
?????目錄??????????0??2014-01-19?19:41??MD5校正工具\obj\Debug
?????目錄??????????0??2014-01-19?20:26??MD5校正工具\obj\Release
?????目錄??????????0??2014-01-19?19:41??MD5校正工具\Properties
............此處省略6個文件信息
- 上一篇:C# 排列組合(類庫很強大)
- 下一篇:全角半角轉換/md5加密 等
評論
共有 條評論