You've already forked go-digest
mirror of
https://github.com/opencontainers/go-digest.git
synced 2025-07-06 08:02:29 +03:00
digest: update package methods to reflect changes
We made a change to call the _hex_ portion the _encoded_ portion and this makes a few updates to make that clearer for prospective users of this package. Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
@ -125,6 +125,14 @@ func (a Algorithm) Hash() hash.Hash {
|
||||
return algorithms[a].New()
|
||||
}
|
||||
|
||||
// Encode encodes the raw bytes of a digest, typically from a hash.Hash, into
|
||||
// the encoded portion of the digest.
|
||||
func (a Algorithm) Encode(d []byte) string {
|
||||
// TODO(stevvooe): Currently, all algorithms use a hex encoding. When we
|
||||
// add support for back registration, we can modify this accordingly.
|
||||
return fmt.Sprintf("%x", d)
|
||||
}
|
||||
|
||||
// FromReader returns the digest of the reader using the algorithm.
|
||||
func (a Algorithm) FromReader(rd io.Reader) (Digest, error) {
|
||||
digester := a.Digester()
|
||||
|
Reference in New Issue
Block a user