hash_sha256
Compute the SHA-256 (256-bit) hash of a UTF-8 string. Returns a 64-character lowercase hexadecimal digest.
SHA-256 is the most widely used secure hash algorithm and is recommended for all new applications that require a cryptographic hash.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | The UTF-8 string to hash. |
Response
| Field | Type | Description |
|---|---|---|
hash | string | Lowercase hexadecimal digest. |
Examples
Hash a non-empty string
{
"input": "hello world"
}
Result:
{
"hash": "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9"
}
Hash an empty string
The SHA-256 digest of the empty string is a well-known constant and a useful baseline for verifying tool output:
{
"input": ""
}
Result:
{
"hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
}
Errors
Each failure carries a precise code in the response. Argument-schema and server errors are JSON-RPC protocol errors; a rejected value is returned as a tool result with isError: true (so the agent can read the code and self-correct).
| Code | When | Delivered as |
|---|---|---|
invalid_arguments | The input field is missing or not a string. | protocol error (invalid_params) |
internal_error | An unexpected server error. | protocol error (internal_error) |
Notes
- The input is always treated as a UTF-8 string. If you need to hash raw bytes, hex-encode them first.
- The digest is always 64 lowercase hex characters (256 bits).
- SHA-256 output is deterministic — the same input always produces the same digest.