Skip to content

Instantly share code, notes, and snippets.

@hatelove
Created April 30, 2019 05:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hatelove/92c92de6a6679aaae22ccf0aa948bb10 to your computer and use it in GitHub Desktop.
Save hatelove/92c92de6a6679aaae22ccf0aa948bb10 to your computer and use it in GitHub Desktop.
Sha256 sample code
public string GetHash(string plainText)
{
var crypt = new System.Security.Cryptography.SHA256Managed();
var hash = new StringBuilder();
var crypto = crypt.ComputeHash(Encoding.UTF8.GetBytes(plainText));
foreach (var theByte in crypto)
{
hash.Append(theByte.ToString("x2"));
}
return hash.ToString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment