Encrypt.cs 568 B

12345678910111213141516171819202122232425
  1. using System.Security.Cryptography;
  2. using System.Text;
  3. namespace Cafe
  4. {
  5. public class Encrypt
  6. {
  7. public static string Hash(string password)
  8. {
  9. byte[] bytes = Encoding.Unicode.GetBytes(password);
  10. MD5CryptoServiceProvider CSP = new MD5CryptoServiceProvider();
  11. byte[] byteHash = CSP.ComputeHash(bytes);
  12. string hash = string.Empty;
  13. foreach (byte b in byteHash)
  14. {
  15. hash += string.Format("{0:x2}", b);
  16. }
  17. return hash;
  18. }
  19. }
  20. }