1package digest
2
3import "hash"
4
5// Digester calculates the digest of written data. Writes should go directly
6// to the return value of Hash, while calling Digest will return the current
7// value of the digest.
8type Digester interface {
9	Hash() hash.Hash // provides direct access to underlying hash instance.
10	Digest() Digest
11}
12
13// digester provides a simple digester definition that embeds a hasher.
14type digester struct {
15	alg  Algorithm
16	hash hash.Hash
17}
18
19func (d *digester) Hash() hash.Hash {
20	return d.hash
21}
22
23func (d *digester) Digest() Digest {
24	return NewDigest(d.alg, d.hash)
25}
26