您好,登錄后才能下訂單哦!
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();//用來將字節拼起來
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;
}
}
}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。