Package io.token.proto
Class ProtoHasher
- java.lang.Object
-
- io.token.proto.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 theProtoHasher
byte array.ProtoHasher
addJson(com.google.protobuf.Message message)
Serializes JSON into canonical fomrat, then adds UTF8 byte array to theProtoHasher
.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.
-
-
-
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 theProtoHasher
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 theProtoHasher
.- Parameters:
message
- message to add- Returns:
- new
ProtoHasher
instance
-
-