{"id":18809669,"url":"https://github.com/opencontainers/go-digest","last_synced_at":"2025-05-14T01:04:54.457Z","repository":{"id":14527194,"uuid":"76684601","full_name":"opencontainers/go-digest","owner":"opencontainers","description":"Common digest package used across the container ecosystem","archived":false,"fork":false,"pushed_at":"2025-01-16T04:16:48.000Z","size":207,"stargazers_count":197,"open_issues_count":11,"forks_count":63,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-04-13T20:44:19.045Z","etag":null,"topics":["container-ecosystem","containers","docker","go","oci"],"latest_commit_sha":null,"homepage":"https://www.opencontainers.org/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/opencontainers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-16T20:47:37.000Z","updated_at":"2025-04-12T15:22:52.000Z","dependencies_parsed_at":"2023-02-18T01:01:34.081Z","dependency_job_id":"251cd39f-88cc-4bcc-a258-0b61b8031715","html_url":"https://github.com/opencontainers/go-digest","commit_stats":{"total_commits":119,"total_committers":29,"mean_commits":4.103448275862069,"dds":0.6386554621848739,"last_synced_commit":"22b78e47854adc56477927aba5f4c930b56af8c9"},"previous_names":["docker/go-digest"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opencontainers%2Fgo-digest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opencontainers%2Fgo-digest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opencontainers%2Fgo-digest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opencontainers%2Fgo-digest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opencontainers","download_url":"https://codeload.github.com/opencontainers/go-digest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248782280,"owners_count":21160716,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["container-ecosystem","containers","docker","go","oci"],"created_at":"2024-11-07T23:17:14.671Z","updated_at":"2025-04-13T20:44:25.299Z","avatar_url":"https://github.com/opencontainers.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# go-digest\n\n[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![Go Reference](https://pkg.go.dev/badge/opencontainers/go-digest)](https://pkg.go.dev/github.com/opencontainers/go-digest)\n[![Go Report Card](https://goreportcard.com/badge/github.com/opencontainers/go-digest)](https://goreportcard.com/report/github.com/opencontainers/go-digest)\n[![CI](https://github.com/opencontainers/go-digest/actions/workflows/test.yml/badge.svg)](https://github.com/opencontainers/go-digest/actions/workflows/test.yml)\n\nCommon digest package used across the container ecosystem.\n\nPlease see the [pkg.go.dev](https://pkg.go.dev/github.com/opencontainers/go-digest) for more information.\n\n# What is a digest?\n\nA digest is just a [hash](https://en.wikipedia.org/wiki/Hash_function).\n\nThe most common use case for a digest is to create a content identifier for use in [Content Addressable Storage](https://en.wikipedia.org/wiki/Content-addressable_storage) systems:\n\n```go\nid := digest.FromBytes([]byte(\"my content\"))\n```\n\nIn the example above, the id can be used to uniquely identify the byte slice \"my content\".\nThis allows two disparate applications to agree on a verifiable identifier without having to trust one another.\n\nAn identifying digest can be verified, as follows:\n\n```go\nif id != digest.FromBytes([]byte(\"my content\")) {\n  return errors.New(\"the content has changed!\")\n}\n```\n\nA `Verifier` type can be used to handle cases where an `io.Reader` makes more sense:\n\n```go\nrd := getContent()\nverifier := id.Verifier()\nio.Copy(verifier, rd)\n\nif !verifier.Verified() {\n  return errors.New(\"the content has changed!\")\n}\n```\n\nUsing [Merkle DAGs](https://en.wikipedia.org/wiki/Merkle_tree), this can power a rich, safe, content distribution system.\n\n# Usage\n\nWhile the [godoc](https://godoc.org/github.com/opencontainers/go-digest) is considered the best resource, a few important items need to be called out when using this package.\n\n1. Make sure to import the hash implementations into your application or the package will panic.\n    You should have something like the following in the main (or other entrypoint) of your application:\n   \n    ```go\n    import (\n        _ \"crypto/sha256\"\n        _ \"crypto/sha512\"\n    )\n    ```\n    This may seem inconvenient but it allows you replace the hash \n    implementations with others, such as https://github.com/stevvooe/resumable.\n \n2. Even though `digest.Digest` may be assemblable as a string, _always_ verify your input with `digest.Parse` or use `Digest.Validate` when accepting untrusted input.\n    While there are measures to avoid common problems, this will ensure you have valid digests in the rest of your application.\n\n3. While alternative encodings of hash values (digests) are possible (for example, base64), this package deals exclusively with hex-encoded digests.\n\n# Stability\n\nThe Go API, at this stage, is considered stable, unless otherwise noted.\n\nAs always, before using a package export, read the [godoc](https://godoc.org/github.com/opencontainers/go-digest).\n\n# Contributing\n\nThis package is considered fairly complete.\nIt has been in production in thousands (millions?) of deployments and is fairly battle-hardened.\nNew additions will be met with skepticism.\nIf you think there is a missing feature, please file a bug clearly describing the problem and the alternatives you tried before submitting a PR.\n\n## Code of Conduct\n\nParticipation in the OpenContainers community is governed by [OpenContainer's Code of Conduct][code-of-conduct].\n\n## Security\n\nIf you find an issue, please follow the [security][security] protocol to report it.\n\n# Copyright and license\n\nCopyright © 2019, 2020 OCI Contributors\nCopyright © 2016 Docker, Inc.\nAll rights reserved, except as follows.\nCode is released under the [Apache 2.0 license](LICENSE).\nThis `README.md` file and the [`CONTRIBUTING.md`](CONTRIBUTING.md) file are licensed under the Creative Commons Attribution 4.0 International License under the terms and conditions set forth in the file [`LICENSE.docs`](LICENSE.docs).\nYou may obtain a duplicate copy of the same license, titled CC BY-SA 4.0, at http://creativecommons.org/licenses/by-sa/4.0/.\n\n[security]: https://github.com/opencontainers/org/blob/master/security\n[code-of-conduct]: https://github.com/opencontainers/org/blob/master/CODE_OF_CONDUCT.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopencontainers%2Fgo-digest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopencontainers%2Fgo-digest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopencontainers%2Fgo-digest/lists"}