namespace MD5Tool
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop, false))
{
e.Effect = DragDropEffects.All;
String[] files = (String[])e.Data.GetData(DataFormats.FileDrop, false);//獲取文件
if (files.Length > 0)
{
textBox1.Text = files[0];
using (FileStream fs = new FileStream(files[0], FileMode.Open))
{
byte[] buffer = new byte[fs.Length];
int count = fs.Read(buffer, 0, buffer.Length);
string s = Encoding.UTF8.GetString(buffer, 0, count);
byte[] bs = Encoding.GetEncoding("gb2312").GetBytes(s);
StringBuilder sb = new StringBuilder();
using (MD5 mm = MD5.Create())
{
byte[] result = mm.ComputeHash(bs);
for (int i = 0,len=result.Length; i < len; i++)
{
sb.Append(result[i].ToString("x2"));
}
}
md5Vlalue.Text = sb.ToString();
}
}
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();//用來將字節(jié)拼起來
if (radioButton2.Checked)
{
string md5Words = textBox1.Text.Trim();//字符串md5要加密的字符串
byte[] bs = Encoding.GetEncoding("gb2312").GetBytes(md5Words);
using (MD5 md5 = MD5.Create())
{
byte[] bsw = md5.ComputeHash(bs);
for (int i = 0; i < bsw.Length; i++)
{
sb.Append(bsw[i].ToString("x2"));
}
}
}
md5Vlalue.Text = sb.ToString();
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
textBox1.ReadOnly = true;
}
}
}
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。