In .NET Framework if we needed to create our own crypto algorithm we could create our own class like:
public class MyAlgorithm: System.Security.Cryptography.HashAlgorithm
{
}
But in .NET Core it seems very limited because of
public abstract class HashAlgorithm : IDisposable
{
protected HashAlgorithm();
public virtual int HashSize { get; }
public byte[] ComputeHash(byte[] buffer);
public byte[] ComputeHash(byte[] buffer, int offset, int count);
public byte[] ComputeHash(Stream inputStream);
public void Dispose();
public abstract void Initialize();
protected virtual void Dispose(bool disposing);
protected abstract void HashCore(byte[] array, int ibStart, int cbSize);
protected abstract byte[] HashFinal();
}
It doesn't have such things as HashSizeValue or State.
Should we still use HashAlgorithm as base class for own algorithms in .NET Core?
HashSizeValue(that is an unexposed property)? you are declaring what is the hash size of your algorithm, through theHashSizeproperty. And forState... If you need aState, you keep the state.HashAlgorithm. Note that they (Microsoft) readded the two fields in November (github.com/dotnet/corefx/commit/…) and in a previous version. If you need them you'll have to readd them.Stateis used byTransformBlock/TransformFinalBlockthat the .NET Core 1.1HashAlgorithmdoesn't implement.