温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

小小MD5器

发布时间:2020-07-09 09:25:03 来源:网络 阅读:339 作者:hacjj 栏目:编程语言

小小MD5器

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


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI