MD5Helper.cs 717 B

1234567891011121314151617181920212223242526
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Security.Cryptography;
  4. using System.Text;
  5. namespace ProductionLineMonitor.Core.Utils
  6. {
  7. public static class MD5Helper
  8. {
  9. /// <summary>
  10. /// 字符串加密
  11. /// </summary>
  12. /// <param name="str">字符串</param>
  13. /// <returns></returns>
  14. public static string To32MD5(this string str)
  15. {
  16. string rev = "";
  17. MD5 md5 = MD5.Create();
  18. byte[] buffer = Encoding.UTF8.GetBytes(str);
  19. byte[] MD5Buffer = md5.ComputeHash(buffer);
  20. foreach (var item in MD5Buffer)
  21. rev += item.ToString("X2");
  22. return rev;
  23. }
  24. }
  25. }