---
agentTools:
  projectIndex: https://xrpl-hooks.readme.io/llms.txt
---

# util_sha512h

Compute an sha512-half over some data

[block:api-header]
{
  "title": "Behaviour"
}
[/block]

* Compute an `SHA512` hash over the data pointed to by `read_ptr`
* Write the first half of the hash to `write_ptr`

[block:api-header]
{
  "title": "Definition"
}
[/block]

[block:code]
{
  "codes": [
    {
      "code": "int64_t util_sha512h (\n    uint32_t write_ptr,\n    uint32_t write_len,\n    uint32_t read_ptr,\n    uint32_t read_len\n);",
      "language": "c"
    }
  ]
}
[/block]

[block:api-header]
{
  "title": "Example"
}
[/block]

[block:code]
{
  "codes": [
    {
      "code": "uint8_t hash_out[32];\nif (util_sha512h(hash_out, 32, data_in_ptr, data_in_len) < 0)\n\trollback(\"Could not generate Hash\", 23, 1);\n  ",
      "language": "c"
    }
  ]
}
[/block]

[block:api-header]
{
  "title": "Parameters"
}
[/block]

[block:parameters]
{
  "data": {
    "h-0": "Name",
    "h-1": "Type",
    "h-2": "Description",
    "0-0": "write_ptr",
    "0-1": "uint32_t",
    "0-2": "Pointer to a buffer the hash will be written to",
    "6-0": "dread_len",
    "6-1": "uint32_t",
    "6-2": "Length of the signed data",
    "7-0": "kread_len",
    "7-1": "uint32_t",
    "7-2": "Length of the public key",
    "1-0": "write_len",
    "1-1": "uint32_t",
    "1-2": "Length of output buffer, should be at least 32.",
    "2-0": "read_ptr",
    "2-1": "uint32_t",
    "2-2": "Pointer to the buffer data will be read from (to compute the hash over)",
    "3-0": "read_len",
    "3-1": "uint32_t",
    "3-2": "Length of input data"
  },
  "cols": 3,
  "rows": 4
}
[/block]

[block:api-header]
{
  "title": "Return Code"
}
[/block]

[block:parameters]
{
  "data": {
    "h-0": "Type",
    "h-1": "Description",
    "0-0": "int64_t",
    "0-1": "The number of bytes written, should always be 32.\n\nIf negative, an error:\n`OUT_OF_BOUNDS`\n- pointers/lengths specified outside of hook memory.\n\n`TOO_SMALL`\n- Output buffer isn't large enough"
  },
  "cols": 2,
  "rows": 1
}
[/block]