Digest returns the lower hex digest of the blobref, without the e.g. "sha224-" prefix. It panics if r is zero.
()
| 132 | // Digest returns the lower hex digest of the blobref, without |
| 133 | // the e.g. "sha224-" prefix. It panics if r is zero. |
| 134 | func (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 | |
| 150 | func (r Ref) DigestPrefix(digits int) string { |
| 151 | v := r.Digest() |