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;
}
}
}
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
网页标题:小小MD5器-创新互联
文章网址:http://lswzjz.com/article/pepod.html