Created
December 11, 2014 20:20
-
-
Save jamesrcounts/322cf6da0234fb3ef68c to your computer and use it in GitHub Desktop.
Snippet to create a hash as a hex string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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