GlobalVariable.cs 1.2 KB

12345678910111213141516171819202122232425262728293031
  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 Shaker.Model
  8. {
  9. public static class GlobalVariable
  10. {
  11. public static string ClientIDKey = "clientid";
  12. public static string ShakerIDKey = "shakerid";
  13. public static string UserIDKey = "shakerid";
  14. public static string MD5Encrypt32(string password)
  15. {
  16. string cl = password;
  17. string pwd = "";
  18. MD5 md5 = MD5.Create(); //实例化一个md5对像
  19. // 加密后是一个字节类型的数组,这里要注意编码UTF8/Unicode等的选择 
  20. byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(cl));
  21. // 通过使用循环,将字节类型的数组转换为字符串,此字符串是常规字符格式化所得
  22. for (int i = 0; i < s.Length; i++)
  23. {
  24. // 将得到的字符串使用十六进制类型格式。格式后的字符是小写的字母,如果使用大写(X)则格式后的字符是大写字符
  25. pwd = pwd + s[i].ToString("X2");
  26. }
  27. return pwd;
  28. }
  29. }
  30. }