Data.HashFunction icon indicating copy to clipboard operation
Data.HashFunction copied to clipboard

Support Span<byte> as Hash-function input

Open aKzenT opened this issue 6 years ago • 0 comments

It would be very useful for the hash functions to accept a ReadOnlySpan instead of only Stream and byte[]. More and more .NET apis are enabled for use with the various Span-datatypes and so it also happens quite often, that instead of a byte[] you are dealing with a Span, which cannot directly be used with this library.

Another advantage is the possibility to cast between various types of Span-types with the help of MemoryMarshal. This makes it possible to cast a string to a ReadOnlySpan without having to encode or copy the string first. As I often want to compute hashes from strings, this would drastically improve the performance and reduce needed allocations.

I would also be happy if this would only be supported in the block-transformer interfaces in the beginning, where you already support ArraySegment.

aKzenT avatar Jan 11 '20 19:01 aKzenT