using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Security.Cryptography; using System.Text; namespace StoreHub.KJDWebService.Commons { public class EncrypUtil { /// /// 加密算法 /// /// 加密字符串 /// public static string Encryption(int s) { string sign = $"{s}sdhewu*/fhAAue48485ew5+5%@3485esGFFHFD"; return GetMd5(sign); } /// /// MD5加密 /// /// /// public static string GetMd5(string instring) { byte[] result = Encoding.Default.GetBytes(instring.Trim()); MD5 md5 = new MD5CryptoServiceProvider(); byte[] output = md5.ComputeHash(result); return BitConverter.ToString(output).Replace("-", ""); } /// /// 获取文件MD5值 /// /// /// public static string GetFileMd5(string FilePath) { try { FileStream get_file = new FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.Read); System.Security.Cryptography.MD5CryptoServiceProvider get_md5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); byte[] hash_byte = get_md5.ComputeHash(get_file); string resule = System.BitConverter.ToString(hash_byte); resule = resule.Replace("-", ""); get_file.Close(); return resule; } catch (Exception e) { return e.ToString(); } } } }