Hashing a string with SHA-256

Hashing a string with SHA-256:


static string SHA256(string message)
{
  StringBuilder hex = new StringBuilder();
  byte[] buffer = new SHA256Managed().ComputeHash(Encoding.ASCII.GetBytes(message));
  foreach (byte b in buffer)
  {
    hex.Append(b.ToString("X2"));
  }

  return hex.ToString();
}

 

Reference:
https://stackoverflow.com/questions/12416249/hashing-a-string-with-sha256