import ( "github.com/docker/distribution/digest" "crypto/sha256" ) data := []byte("hello world") digest := digest.NewDigestFromBytes(digest.AlgorithmSHA256, sha256.Sum256(data)[:])
import ( "github.com/docker/distribution/digest" ) digest1, _ := digest.ParseDigest("sha256:abcde...") digest2, _ := digest.ParseDigest("sha256:abcde...") if digest1 == digest2 { fmt.Println("Digests are equal!") }In this example, we parse two digests from their string representation using ParseDigest. We then compare the two digests using the == operator. Overall, the `github.com/docker/distribution/digest` package in Go provides convenient methods for computing and comparing message digests using various algorithms like SHA and MD5. This can be useful in applications that require verifying the integrity of data or comparing checksums.