Merge pull request #2097 from stevvooe/digest-from-string
digest: add FromString helper to Digest
This commit is contained in:
commit
84aa95ebd0
2 changed files with 10 additions and 0 deletions
|
@ -80,6 +80,11 @@ func FromBytes(p []byte) Digest {
|
||||||
return Canonical.FromBytes(p)
|
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
|
// Validate checks that the contents of d is a valid digest, returning an
|
||||||
// error if not.
|
// error if not.
|
||||||
func (d Digest) Validate() error {
|
func (d Digest) Validate() error {
|
||||||
|
|
|
@ -129,6 +129,11 @@ func (a Algorithm) FromBytes(p []byte) Digest {
|
||||||
return digester.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
|
// TODO(stevvooe): Allow resolution of verifiers using the digest type and
|
||||||
// this registration system.
|
// this registration system.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue