- using System;
- using System.Text;
- using System.Security.Cryptography;
-
- namespace Common
- {
-
-
-
-
-
- public sealed class MD5Hashing
- {
- private static MD5 md5 = MD5.Create();
-
- private MD5Hashing()
- {
- }
-
-
-
-
-
- public static string HashString(string sourceString)
- {
- return HashString(Encoding.UTF8, sourceString);
- }
-
-
-
-
-
-
- public static string HashString(Encoding encode, string sourceString)
- {
- byte[] source = md5.ComputeHash(encode.GetBytes(sourceString));
- StringBuilder sBuilder = new StringBuilder();
- for (int i = 0; i < source.Length; i++)
- {
- sBuilder.Append(source[i].ToString("x2"));
- }
- return sBuilder.ToString();
- }
- }
- }