diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ diff --git a/digest.go b/digest.go index 518b5e7..38aa223 100644 --- a/digest.go +++ b/digest.go @@ -30,7 +30,7 @@ import ( // // The following is an example of the contents of Digest types: // -// sha256:7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc +// sha256:7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc // // This allows to abstract the digest behind this type and work only in those // terms. @@ -146,6 +146,16 @@ func (d Digest) String() string { return string(d) } +// IsIdenticalTo compares this digest to any other, inclusive of the hashing algorithm used +func (d Digest) IsIdenticalTo(o Digest) bool { + return string(d) == string(o) +} + +// IsEmpty does what it says (an empty digest is an empty string) +func (d Digest) IsEmpty() bool { + return len(d) == 0 +} + func (d Digest) sepIndex() int { i := strings.Index(string(d), ":")