MD5.cs 708 B

12345678910111213141516171819202122232425
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Security.Cryptography;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace wispro.sp.utility
  8. {
  9. public class MD5Utility
  10. {
  11. public static string GetMD5(string myString)
  12. {
  13. MD5 md5 = new MD5CryptoServiceProvider();
  14. byte[] fromData = System.Text.Encoding.Unicode.GetBytes(myString);
  15. byte[] targetData = md5.ComputeHash(fromData);
  16. string byte2String = null;
  17. for (int i = 0; i < targetData.Length; i++)
  18. {
  19. byte2String += targetData[i].ToString("x");
  20. }
  21. return byte2String;
  22. }
  23. }
  24. }