Giter Site home page Giter Site logo

objecthash-proto's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.