MCPcopy
hub / github.com/perkeep/perkeep / Digest

Method Digest

pkg/blob/ref.go:134–148  ·  view source on GitHub ↗

Digest returns the lower hex digest of the blobref, without the e.g. "sha224-" prefix. It panics if r is zero.

()

Source from the content-addressed store, hash-verified

132// Digest returns the lower hex digest of the blobref, without
133// the e.g. "sha224-" prefix. It panics if r is zero.
134func (r Ref) Digest() string {
135 if r.digest == nil {
136 panic("Digest called on invalid Ref")
137 }
138 bs := r.digest.bytes()
139 buf := getBuf(len(bs) * 2)[:0]
140 defer putBuf(buf)
141 for _, b := range bs {
142 buf = append(buf, hexDigit[b>>4], hexDigit[b&0xf])
143 }
144 if o, ok := r.digest.(otherDigest); ok && o.odd {
145 buf = buf[:len(buf)-1]
146 }
147 return string(buf)
148}
149
150func (r Ref) DigestPrefix(digits int) string {
151 v := r.Digest()

Callers 5

DigestPrefixMethod · 0.95
TestParseFunction · 0.80
blobFileBaseNameFunction · 0.80
blobDirectoryMethod · 0.80
resolvePrefixHopMethod · 0.80

Calls 3

getBufFunction · 0.70
putBufFunction · 0.70
bytesMethod · 0.65

Tested by 1

TestParseFunction · 0.64