Skip to main content

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

NameTypeRequiredDescription
hashAlgorithmintegerYesHash algorithm byte code (e.g., 0 = SHA-256). See HashFunction.getHashFunction().
secretstringYesData to hash. If secretIsText = true, treated as UTF-8 text. If secretIsText = false, treated as hex-encoded bytes.
secretIsTextbooleanNoIf true, secret is treated as plain text. If false, secret is treated as hex string. Defaults to false.

Response

{
"hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
}

Response Fields

FieldTypeDescription
hashstringHex-encoded hash value.

Error Responses

ConditionResponse
Invalid hash algorithmJSONResponses.INCORRECT_HASH_ALGORITHM
Invalid secret formatJSONResponses.INCORRECT_SECRET
Missing secretJSONResponses.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"