Closed
Description
It is often useful to be able to copy the internal state for blake2b, such as if you want to compute Blake2b(msg || tag1)
and Blake2b(msg || tag2)
, and you want to avoid double-computing what results from updating msg
.
I've added a clone method to do this here. This is an improvement that can't be made in applications using the library, since the digest struct isn't exported.
Since the publicly visible interface for digest is hash.Hash, I made the method for cloning func Clone(h hash.Hash) (*digest, error)
instead of func (d *digest) Clone (*digest)
.
This could alternatively be added as a method that everything which implements the hash.Hash interface must implement, since there have been requests for this before. (Link 1, Link 2)