标签:button class 字符串 app visual win orm cti play
说明:本文介绍的内容就是怎么把一个字符串转换为MD5加密字符串
1、界面设计
两个文本框
原字符串输入文本框(textbox ,name:txtString)
MD5加密字符串文本框(textbox ,name: txtMD5)
转换按钮(button,text:‘转换’,name:btChange)
2、后台代码
开发工具visual studio 2010 c#语言
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; using System.Security.Cryptography; namespace FrMD5 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void btChange_Click(object sender, EventArgs e) { txtMD5.Text = GetMD5(txtString.Text.Trim()); } public static string GetMD5(string st) { MD5 md5 = new MD5CryptoServiceProvider(); byte[] t = md5.ComputeHash(Encoding.GetEncoding("utf-8").GetBytes(st)); StringBuilder sb = new StringBuilder(32); for (int i = 0; i < t.Length; i++) { sb.Append(t[i].ToString("x").PadLeft(2, ‘0‘)); } return sb.ToString(); } } }
标签:button class 字符串 app visual win orm cti play
原文地址:http://www.cnblogs.com/net064/p/8004619.html