//************************************************************************ // author: yuzhengyang // date: 2018.3.27 - 2018.6.3 // desc: MD5 工具 // Copyright (c) yuzhengyang. All rights reserved. //************************************************************************ using System; using System.Collections.Generic; using System.Linq; using System.Security.Cryptography; using System.Text; namespace Azylee.Core.DataUtils.EncryptUtils { public class MD5Tool { /// /// 给一个字符串进行MD5加密 /// /// 待加密字符串 /// 加密后的字符串 public static string Encrypt(string s) { if (s != null) { try { byte[] buffer = Encoding.UTF8.GetBytes(s); return Encrypt(buffer); } catch { } } return ""; } public static string Encrypt(byte[] data) { string result = ""; if (data != null) { try { HashAlgorithm algorithm = MD5.Create(); byte[] hashBytes = algorithm.ComputeHash(data); result = BitConverter.ToString(hashBytes).Replace("-", ""); } catch { } } return result; } } }