Classes that implement System.Security.Cryptography.ICryptoTransform are not thread safe.

Any object that implements System.Security.Cryptography.ICryptoTransform should not be used in concurrent threads as the instance members of such object are also not thread safe.

Potential problems may not be evident at first, but can range from explicit errors such as exceptions, to incorrect results when sharing an instance of such object in multiple threads.

Verify that the object is not being shared across threads.

If it is shared accross instances. Consider changing the code to use a non-static object of type System.Security.Cryptography.ICryptoTransform instead.

As an alternative, you could also look into using ThreadStatic attribute, but make sure you read the initialization remarks on the documentation.

This example demonstrates the dangers of using a static System.Security.Cryptography.ICryptoTransform in such a way that the results may be incorrect.

A simple fix is to change the _sha field from being a static member to an instance one by removing the static keyword.

  • Microsoft documentation, ThreadStaticAttribute Class.
  • Stack Overflow, Why does SHA1.ComputeHash fail under high load with many threads?.