using System.Text; using System.Security.Cryptography; namespace jsonapi.Library { public class SHA256HashGenerator { public static SHA256HashGenerator GetInstance() { return new SHA256HashGenerator(); } public string Get(string text) { using (SHA256 hash = SHA256.Create()) { byte[] hashValue = hash.ComputeHash(Encoding.UTF8.GetBytes(text)); StringBuilder builder = new StringBuilder(); for (int i = 0; i < hashValue.Length; i++) { builder.Append(hashValue[i].ToString("X2")); //Format as hexidecimal } return builder.ToString(); } } } }