digest: cleanup digester and verifier creation
Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
parent
ad80b3d492
commit
e37baed88e
7 changed files with 159 additions and 141 deletions
|
@ -123,6 +123,20 @@ func (d Digest) Algorithm() Algorithm {
|
|||
return Algorithm(d[:d.sepIndex()])
|
||||
}
|
||||
|
||||
// Verifier returns a writer object that can be used to verify a stream of
|
||||
// content against the digest. If the digest is invalid, an error will be
|
||||
// returned.
|
||||
func (d Digest) Verifier() (Verifier, error) {
|
||||
if err := d.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return hashVerifier{
|
||||
hash: d.Algorithm().Hash(),
|
||||
digest: d,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Hex returns the hex digest portion of the digest. This will panic if the
|
||||
// underlying digest is not in a valid format.
|
||||
func (d Digest) Hex() string {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue