Hash
Calculates a cryptographic hash using the specified algorithm. Supports multiple hash algorithms.
Request
GET /nxt?requestType=hash&hashAlgorithm=<algorithm>&secret=<data>&secretIsText=<boolean>
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
hashAlgorithm | integer | Yes | Hash algorithm byte code (e.g., 0 = SHA-256). See HashFunction.getHashFunction(). |
secret | string | Yes | Data to hash. If secretIsText = true, treated as UTF-8 text. If secretIsText = false, treated as hex-encoded bytes. |
secretIsText | boolean | No | If true, secret is treated as plain text. If false, secret is treated as hex string. Defaults to false. |
Response
{
"hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
}
Response Fields
| Field | Type | Description |
|---|---|---|
hash | string | Hex-encoded hash value. |
Error Responses
| Condition | Response |
|---|---|
| Invalid hash algorithm | JSONResponses.INCORRECT_HASH_ALGORITHM |
| Invalid secret format | JSONResponses.INCORRECT_SECRET |
| Missing secret | JSONResponses.MISSING_SECRET |
Notes
- This endpoint does not require the blockchain to be running (
requireBlockchain = false). - Not chain-specific.
- Does not require admin password authentication (
requirePassword = false).
Source: Hash.java.
Example
curl "http://localhost:22024/nxt?requestType=hash&hashAlgorithm=0&secret=hello&secretIsText=true"