Skip to content

Instantly share code, notes, and snippets.

@jamesrcounts
Created December 11, 2014 20:20
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 jamesrcounts/322cf6da0234fb3ef68c to your computer and use it in GitHub Desktop.
Save jamesrcounts/322cf6da0234fb3ef68c to your computer and use it in GitHub Desktop.
Snippet to create a hash as a hex string
public static async Task<string> CreateHash(Stream stream)
{
byte[] b;
using (var ctx = new System.Security.Cryptography.SHA256Managed())
{
var input = await stream.ReadDataAsync();
b = ctx.ComputeHash(input);
}
return string.Join(string.Empty, b.Select(i => i.ToString("X2")));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment