Skip to content

Commit 7f14c37

Browse files
committed
Add two abstraction helpers
Signed-off-by: Nima Talebi <[email protected]>
1 parent 8a95807 commit 7f14c37

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

digest.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,21 @@ func (d Digest) Encoded() string {
140140
return string(d[d.sepIndex()+1:])
141141
}
142142

143-
// Hex is deprecated. Please use Digest.Encoded.
143+
// IsIdenticalTo compares this digest to any other, inclusive of the hashing algorithm used
144+
func (d Digest) IsIdenticalTo(o Digest) bool {
145+
return string(d) == string(o)
146+
}
147+
148+
// Deprecated: Hex has been deprecated in favor of Digest.Encoded
144149
func (d Digest) Hex() string {
145150
return d.Encoded()
146151
}
147152

153+
// IsEmpty does what it says (an empty digest is an empty string)
154+
func (d Digest) IsEmpty() bool {
155+
return len(d.String()) == 0
156+
}
157+
148158
func (d Digest) String() string {
149159
return string(d)
150160
}

0 commit comments

Comments
 (0)