Just a Ordinary Programmer
MD5 กับ C# .NET
ใครเคยเขียน php ก็มักจะใช้ function md5 บ้างใช่ไหม แล้ว .NET ล่ะ? md5 มันอยู่ไหน
เขียนเองเลยละกัน ประมาณนี้คับ
public string GetMD5Hash(string input) { System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider(); byte[] bs = System.Text.Encoding.UTF8.GetBytes(input); bs = x.ComputeHash(bs); System.Text.StringBuilder s = new System.Text.StringBuilder(); foreach (byte b in bs) { s.Append(b.ToString("x2").ToLower()); } string password = s.ToString(); return password; }
| Print article | This entry was posted by Krucode on February 22, 2010 at 10:58 am, and is filed under Uncategorized. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |