MCPcopy Create free account
hub / github.com/opencontainers/go-digest / FromBytes

Method FromBytes

algorithm.go:158–171  ·  view source on GitHub ↗

FromBytes digests the input and returns a Digest.

(p []byte)

Source from the content-addressed store, hash-verified

156
157// FromBytes digests the input and returns a Digest.
158func (a Algorithm) FromBytes(p []byte) Digest {
159 digester := a.Digester()
160
161 if _, err := digester.Hash().Write(p); err != nil {
162 // Writes to a Hash should never fail. None of the existing
163 // hash implementations in the stdlib or hashes vendored
164 // here can return errors from Write. Having a panic in this
165 // condition instead of having FromBytes return an error value
166 // avoids unnecessary error handling paths in all callers.
167 panic("write to hash function returned error: " + err.Error())
168 }
169
170 return digester.Digest()
171}
172
173// FromString digests the string input and returns a Digest.
174func (a Algorithm) FromString(s string) Digest {

Callers 3

FromStringMethod · 0.95
FromBytesFunction · 0.80
TestFromsFunction · 0.80

Calls 4

DigesterMethod · 0.95
WriteMethod · 0.80
HashMethod · 0.65
DigestMethod · 0.65

Tested by 1

TestFromsFunction · 0.64