hash: add MultiHasher.Sum() to retrieve a single specific hash

This commit is contained in:
buengese 2020-09-14 23:02:13 +02:00 committed by buengese
parent ceeac84cfe
commit 2812816142
1 changed files with 9 additions and 0 deletions

View File

@ -238,6 +238,15 @@ func (m *MultiHasher) Sums() map[Type]string {
return dst
}
// Sum returns the specified hash from the multihasher
func (m *MultiHasher) Sum(hashType Type) ([]byte, error) {
h, ok := m.h[hashType]
if !ok {
return nil, ErrUnsupported
}
return h.Sum(nil), nil
}
// Size returns the number of bytes written
func (m *MultiHasher) Size() int64 {
return m.size