Exemple #1
0
 static ImmutableArray <byte> CalculateChecksum(byte[] buffer, int offset, int count, SourceHashAlgorithm algorithmId)
 {
     using (HashAlgorithm algorithm = CryptographicHashProvider.TryGetAlgorithm(algorithmId))
     {
         return(ImmutableArray.Create(algorithm.ComputeHash(buffer, offset, count)));
     }
 }
Exemple #2
0
 static ImmutableArray <byte> CalculateChecksum(Stream stream, SourceHashAlgorithm algorithmId)
 {
     using (HashAlgorithm algorithm = CryptographicHashProvider.TryGetAlgorithm(algorithmId))
     {
         if (stream.CanSeek)
         {
             stream.Seek(0L, SeekOrigin.Begin);
         }
         return(ImmutableArray.Create(algorithm.ComputeHash(stream)));
     }
 }