12345678910111213141516171819202122232425262728293031323334353637 |
- using System.Security.Cryptography;
- using System.Text;
- namespace ERP.Framework.Utils
- {
- public class CryptoUtil
- {
- public static string BCHash(string password)
- {
- return BCrypt.Net.BCrypt.HashPassword(password);
- }
- public static bool BCValify(string password, string hash)
- {
- return BCrypt.Net.BCrypt.Verify(password, hash);
- }
- public static string MD5(string input)
- {
- string salt = "seed_567890Omnbvc_Salt";
- string str = input + salt;
- using (MD5 md5 = System.Security.Cryptography.MD5.Create())
- {
- byte[] inputBytes = Encoding.UTF8.GetBytes(str);
- byte[] hashBytes = md5.ComputeHash(inputBytes);
- StringBuilder builder = new StringBuilder();
- for (int i = 0; i < hashBytes.Length; i++)
- {
- builder.Append(hashBytes[i].ToString("x2"));
- }
- return builder.ToString();
- }
- }
- }
- }
|