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 consistent mapping and stable output, then hashes the resulting JSON object.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for the operation, used for logging.
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.