CryptoUtil.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System.Security.Cryptography;
  2. using System.Text;
  3. namespace ERP.Framework.Utils
  4. {
  5. public class CryptoUtil
  6. {
  7. public static string BCHash(string password)
  8. {
  9. return BCrypt.Net.BCrypt.HashPassword(password);
  10. }
  11. public static bool BCValify(string password, string hash)
  12. {
  13. return BCrypt.Net.BCrypt.Verify(password, hash);
  14. }
  15. public static string MD5(string input)
  16. {
  17. string salt = "seed_567890Omnbvc_Salt";
  18. string str = input + salt;
  19. using (MD5 md5 = System.Security.Cryptography.MD5.Create())
  20. {
  21. byte[] inputBytes = Encoding.UTF8.GetBytes(str);
  22. byte[] hashBytes = md5.ComputeHash(inputBytes);
  23. StringBuilder builder = new StringBuilder();
  24. for (int i = 0; i < hashBytes.Length; i++)
  25. {
  26. builder.Append(hashBytes[i].ToString("x2"));
  27. }
  28. return builder.ToString();
  29. }
  30. }
  31. }
  32. }