Skip to main content

ComputeHash

No overview available.

def ComputeHash(
ctx: context.Context,
pb: proto.Message
) - > []byte, error

Generates a deterministic hash in bytes for a given protobuf object. This function marshals the protobuf object to JSON to ensure a stable output, as direct protobuf marshalling does not guarantee stable output due to its handling of unknown fields and field ordering.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for the operation, used for logging purposes.
pbproto.MessageThe protobuf object for which to compute a deterministic hash.

Returns

TypeDescription
[]byte, errorA byte array representing the deterministic hash of the protobuf object, or an error if marshalling or hashing fails.