Skip to content

Commit

Permalink
digest: add FromString helper to Digest
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen J Day <stephen.day@docker.com>
  • Loading branch information
stevvooe committed Dec 7, 2016
1 parent 2a35100 commit 85994fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions digest/digest.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ func FromBytes(p []byte) Digest {
return Canonical.FromBytes(p)
}

// FromString digests the input and returns a Digest.
func FromString(s string) Digest {
return Canonical.FromString(s)
}

// Validate checks that the contents of d is a valid digest, returning an
// error if not.
func (d Digest) Validate() error {
Expand Down
5 changes: 5 additions & 0 deletions digest/digester.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ func (a Algorithm) FromBytes(p []byte) Digest {
return digester.Digest()
}

// FromString digests the string input and returns a Digest.
func (a Algorithm) FromString(s string) Digest {
return a.FromBytes([]byte(s))
}

// TODO(stevvooe): Allow resolution of verifiers using the digest type and
// this registration system.

Expand Down

0 comments on commit 85994fc

Please sign in to comment.