WinRT Checksum for large files
There is a good question about this.
Also there is a code. I have used MD5 algorithm for my purposes.
public async Task<string> GetFileChecksumAsync(string fileName)
{
HashAlgorithmProvider alg = Windows.Security.Cryptography.Core.HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Md5);
IStorageFile stream = await openFile(fileName);
using (var inputStream = await stream.OpenReadAsync())
{
Windows.Storage.Streams.Buffer buffer = new Windows.Storage.Streams.Buffer(BUFFER_SIZE);
var hash = alg.CreateHash();
while (true)
{
await inputStream.ReadAsync(buffer, BUFFER_SIZE, InputStreamOptions.None);
if (buffer.Length > 0)
hash.Append(buffer);
else
break;
}
return CryptographicBuffer.EncodeToHexString(hash.GetValueAndReset()).ToUpper();
}
}