import ( "fmt" "github.com/docker/distribution/digest" ) data := []byte("hello world") d := digest.FromBytes(data) fmt.Println(d) // Output: sha256:94afd46d419dee2c5d94e5f2c5292d6c17307ce52b3e973670f4330b216afc5f
import ( "fmt" "github.com/docker/distribution/digest" ) raw := "sha256:94afd46d419dee2c5d94e5f2c5292d6c17307ce52b3e973670f4330b216afc5f" d, err := digest.Parse(raw) if err != nil { panic(err) } fmt.Println(d.Algorithm(), d.Hex()) // Output: sha256 94afd46d419dee2c5d94e5f2c5292d6c17307ce52b3e973670f4330b216afc5f
import ( "fmt" "github.com/docker/distribution/digest" ) d1 := digest.FromString("sha256:abc123") d2 := digest.FromString("sha256:abc123") if d1 == d2 { fmt.Println("Digests are equal!") } else { fmt.Println("Digests are not equal!") } // Output: Digests are equal!In conclusion, the `github.com/docker/distribution/digest` package library in Go provides functionality for creating and validating content digests. It is used for implementing the Docker distribution specification.