using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ServiceShared.Crypto { public static class MD5 { /// /// Encryptes a string value in md5 hash /// /// string value that should be encrypted in MD5 hash /// Returns MD5 hash public static string Encrypt(string value) { string result = null; try { byte[] bytes = Encoding.UTF8.GetBytes(value); using (System.Security.Cryptography.MD5 hash = System.Security.Cryptography.MD5.Create()) { byte[] hashedInputBytes = hash.ComputeHash(bytes); StringBuilder hashedInputStringBuilder = new StringBuilder(128); foreach (var b in hashedInputBytes) { hashedInputStringBuilder.Append(b.ToString("X2")); } result = hashedInputStringBuilder.ToString().ToLower(); } } catch { result = null; } return result; } } }