Class ProtoHasher


  • public final class ProtoHasher
    extends java.lang.Object
    Computes content hash of a protobuf message.
    • Constructor Summary

      Constructors 
      Constructor Description
      ProtoHasher()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ProtoHasher add​(com.google.protobuf.Message message)
      Adds message to the ProtoHasher byte array.
      ProtoHasher addJson​(com.google.protobuf.Message message)
      Serializes JSON into canonical fomrat, then adds UTF8 byte array to the ProtoHasher.
      byte[] hash()
      Gets hash byte array.
      static byte[] hash​(com.google.protobuf.Message message)
      Computes hash of the message.
      static java.lang.String hashAndSerialize​(com.google.protobuf.Message message)
      Serializes hashes message and returns in human readable format.
      static java.lang.String hashAndSerializeJson​(com.google.protobuf.Message message)
      Serializes message into Json, then hashes and returns in human readable format.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ProtoHasher

        public ProtoHasher()
    • Method Detail

      • hashAndSerializeJson

        public static java.lang.String hashAndSerializeJson​(com.google.protobuf.Message message)
        Serializes message into Json, then hashes and returns in human readable format.
        Parameters:
        message - the message to be serialized
        Returns:
        the serialized hash of the message
      • hashAndSerialize

        public static java.lang.String hashAndSerialize​(com.google.protobuf.Message message)
        Serializes hashes message and returns in human readable format.
        Parameters:
        message - the message to be serialized
        Returns:
        the serialized hash of the message
      • hash

        public static byte[] hash​(com.google.protobuf.Message message)
        Computes hash of the message.
        Parameters:
        message - message
        Returns:
        hash byte array
      • hash

        public byte[] hash()
        Gets hash byte array.
        Returns:
        hash byte array
      • add

        public ProtoHasher add​(com.google.protobuf.Message message)
        Adds message to the ProtoHasher byte array.
        Parameters:
        message - message to add
        Returns:
        new ProtoHasher instance
      • addJson

        public ProtoHasher addJson​(com.google.protobuf.Message message)
        Serializes JSON into canonical fomrat, then adds UTF8 byte array to the ProtoHasher.
        Parameters:
        message - message to add
        Returns:
        new ProtoHasher instance