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
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for the operation, used for logging purposes. |
| pb | proto.Message | The protobuf object for which to compute a deterministic hash. |
Returns
| Type | Description |
|---|---|
[]byte, error | A byte array representing the deterministic hash of the protobuf object, or an error if marshalling or hashing fails. |