{"id":18715121,"url":"https://github.com/cerbos/protoc-gen-go-hashpb","last_synced_at":"2025-04-12T13:08:25.143Z","repository":{"id":57652698,"uuid":"450203306","full_name":"cerbos/protoc-gen-go-hashpb","owner":"cerbos","description":"Generate hash functions for protocol buffer messages","archived":false,"fork":false,"pushed_at":"2024-08-02T07:27:51.000Z","size":635,"stargazers_count":6,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-08-02T09:07:02.403Z","etag":null,"topics":["go","golang","hash","protobuf","protobuf-plugin","protocol-buffers"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cerbos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-20T17:58:40.000Z","updated_at":"2024-08-02T07:27:49.000Z","dependencies_parsed_at":"2023-07-12T21:15:16.702Z","dependency_job_id":"2fe14105-e96f-45c2-a744-3fbf17106d92","html_url":"https://github.com/cerbos/protoc-gen-go-hashpb","commit_stats":null,"previous_names":["cerbos/hashpb"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cerbos%2Fprotoc-gen-go-hashpb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cerbos%2Fprotoc-gen-go-hashpb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cerbos%2Fprotoc-gen-go-hashpb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cerbos%2Fprotoc-gen-go-hashpb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cerbos","download_url":"https://codeload.github.com/cerbos/protoc-gen-go-hashpb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223518540,"owners_count":17158689,"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":["go","golang","hash","protobuf","protobuf-plugin","protocol-buffers"],"created_at":"2024-11-07T13:07:38.638Z","updated_at":"2024-11-07T13:07:39.386Z","avatar_url":"https://github.com/cerbos.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# protoc-gen-go-hashpb\n\nA protobuf plugin to generate hash functions for messages.\n\nHashing messages encoded using Protocol Buffers is tricky because there is [no guarantee that the serialized form is stable](https://developers.google.com/protocol-buffers/docs/encoding) between different implementations, architectures, or even library versions.\nThis plugin generates a hash function that does a depth-first traversal of the populated values (including default values) of the message in field number order and feeds it to the provided `hash.Hash` implementation. Map values are accessed in key order as well. Because of this deterministic traversal order, the hash generated for two identical protobuf messages should be the same.\n\nNOTE: While we have tested this plugin quite extensively, some edge cases may remain. Use at your own risk.\n\n## Install\n\nDownload the latest binary for your environment from https://github.com/cerbos/protoc-gen-go-hashpb/releases.\n\nAlternatively, install from source:\n\n```shell\ngo install github.com/cerbos/protoc-gen-go-hashpb@latest\n```\n\n## Usage\n\n### Generate code\n\nWith `protoc`:\n\n```shell\nprotoc --plugin protoc-gen-go-hashpb=${GOBIN}/protoc-gen-go-hashpb --go_out=. --go-hashpb_out=. *.proto\n```\n\n### Calculate hashes using generated code\n\n```go\nfunc hashMyProto(m *mypb.MyMsg) uint64 {\n    digest := xxhash.New() // any hash.Hash implementation would work\n    m.HashPB(digest, nil)\n    return digest.Sum64()\n}\n```\n\nYou can exclude certain fields from being included in the hash. The field name must be fully qualified.\n\n```go\nignore := map[string]struct{}{\"fully.qualified.package.Message.field_name1\": {}, \"fully.qualified.package.Message.field_name2\":{}}\ndigest := xxhash.New() // any hash.Hash implementation would work\nm.HashPB(digest, ignore)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcerbos%2Fprotoc-gen-go-hashpb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcerbos%2Fprotoc-gen-go-hashpb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcerbos%2Fprotoc-gen-go-hashpb/lists"}