12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- using System.Security.Cryptography;
- using System.Text;
- using ZhonTai.Common.Extensions;
- namespace ZhonTai.Common.Helpers
- {
-
-
-
- public class MD5Encrypt
- {
-
-
-
-
-
- public static string Encrypt16(string password)
- {
- if (password.IsNull())
- return null;
- using (var md5 = MD5.Create())
- {
- return md5.ComputeHash(Encoding.UTF8.GetBytes(password)).ToHex();
- }
- }
-
-
-
-
-
- public static string Encrypt32(string password = "")
- {
- if (password.IsNull())
- return null;
- using (var md5 = MD5.Create())
- {
- string pwd = string.Empty;
- byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(password));
- foreach (var item in s)
- {
- pwd = string.Concat(pwd, item.ToString("X"));
- }
- return pwd;
- }
- }
-
-
-
-
-
- public static string Encrypt64(string password)
- {
- if (password.IsNull())
- return null;
- using (var md5 = MD5.Create())
- {
- byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(password));
- return s.ToBase64();
- }
- }
- }
- }
|