ObjectHash for protocol buffers
Switch branches/tags
Nothing to show
Clone or download
maljub01 Merge pull request #28 from maljub01/remove-constraints
Remove constraints to use the "master" branch from Gopkg.toml
Latest commit 5db4e5a Jun 8, 2018
Permalink
Failed to load latest commit information.
internal Make use of internal packages. May 8, 2018
test_protos Merge pull request #26 from maljub01/test-upstream May 24, 2018
tests Add support for hashing `google.protobuf.Timestamp` protos. May 8, 2018
.gitignore Use go dep to manage dependencies. May 9, 2018
.travis.yml Add quotes around version numbers to avoid interpreting them as floats. May 24, 2018
AUTHORS Add an AUTHORS file and modify copyright headers to refer to the auth… Dec 8, 2017
CONTRIBUTING.md Add licensing and contributing info. Dec 8, 2017
Gopkg.lock Use go dep to manage dependencies. May 9, 2018
Gopkg.toml Remove constraints to use the "master" branch from Gopkg.toml Jun 8, 2018
LICENSE Add licensing and contributing info. Dec 8, 2017
Makefile Use go dep to manage dependencies. May 9, 2018
README.md Add a link to the ObjectHash google group. Feb 16, 2018
basic_hash_functions.go Apply lint suggestions from: golint, go vet, and errcheck. Feb 5, 2018
detection.go Make ObjectHash-Proto compatible with the latest protoc-gen-go. May 15, 2018
detection_test.go Improve the errors returned by the detection module. May 8, 2018
functional_test.go Add support for hashing `google.protobuf.Timestamp` protos. May 8, 2018
hash_entry.go Add an AUTHORS file and modify copyright headers to refer to the auth… Dec 8, 2017
manipulation.go Apply lint suggestions from: golint, go vet, and errcheck. Feb 5, 2018
normalization.go Add an AUTHORS file and modify copyright headers to refer to the auth… Dec 8, 2017
object_hasher.go Make ObjectHash-Proto compatible with the latest protoc-gen-go. May 15, 2018
options.go Improve the documentation for the accepted options. May 8, 2018
protohash.go Apply lint suggestions from: golint, go vet, and errcheck. Feb 5, 2018
well_known_types.go Fix typos. May 15, 2018
well_known_types_test.go Add tests that check how hashTimestamp handles bad inputs. May 8, 2018

README.md

ObjectHash-Proto

Build Status Go Report Card GoDoc

The library is an implementation of Ben Laurie's ObjectHash for protocol buffers.

This implementation is still experimental and until it is stable, protobuf messages are not guaranteed to result in the same value.

Usage

Get a new ProtoHasher instance using the NewHasher method, then call HashProto with a protobuf message to get its ObjectHash:

hasher := protohash.NewHasher()
hash, err := hasher.HashProto(message)

Options

In order to simplify compatibility with other ObjectHash applications, this library exposes the following options that control how the hashing is done:

  1. EnumsAsStrings(): Makes enum values get hashed as strings instead of being hashed as their integer values.

  2. FieldNamesAsKeys(): Makes protobuf message fields use their names as keys instead of using the field tag numbers as keys.

  3. MessageIdentifier(i): Instead of hashing protobuf messages as maps, this makes it possible to distinguish them by using i as the type-identifier that gets used in calculating the ObjectHash of a message.

Those options can be specified in any order as arguments to the NewHasher function. Example:

hasher := protohash.NewHasher(EnumsAsStrings(), MessageIdentifier(`m`), FieldNamesAsKeys())

Help and Discussion