Hashing¶
Compute cryptographic hashes and password KDF hashes.
apicrate-compute-hash¶
Compute a cryptographic digest hash of a given input string. Returns the hex-encoded hash and input length.
Credit cost: 1 credit per call.
Parameters¶
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
yes |
The string to hash. |
|
string |
yes |
Hash algorithm. One of: |
Example¶
Request:
{
"name": "apicrate-compute-hash",
"arguments": {
"input": "hello",
"algorithm": "sha256"
}
}
Response:
{
"algorithm": "sha256",
"hash": "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824",
"input_length": 5
}
Errors¶
Unknown algorithm – only
md5,sha1,sha256, andsha512are supported. Any other value is rejected.Input too long – extremely large input strings are rejected to prevent abuse. Keep inputs within reasonable bounds.
apicrate-hash-password¶
Hash a password using a slow key derivation function (KDF). These algorithms are
intentionally slow to resist brute-force attacks. Use this for storing passwords
securely – not for general-purpose hashing (use apicrate-compute-hash for
that).
Credit cost: 2 credits per call.
Parameters¶
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
yes |
The password to hash. |
|
string |
yes |
KDF algorithm. One of: |
Example¶
Request:
{
"name": "apicrate-hash-password",
"arguments": {
"password": "s3cr3t",
"algorithm": "bcrypt"
}
}
Response:
{
"algorithm": "bcrypt",
"hash": "$2b$12$LJ3m4ys3Lg2dCMkwNYKRce8XQGbHwMEQ7RZsG6H9NKPw0aBvf5KxW",
"parameters": {
"rounds": 12
}
}
Errors¶
Unknown algorithm – only
bcrypt,scrypt, andargon2idare supported. These are KDF algorithms, not digest algorithms – do not passsha256or similar here (useapicrate-compute-hashinstead).Input too long – very long passwords are rejected. Note that
bcrypthas a built-in 72-byte input limit; inputs exceeding this are truncated or rejected depending on the implementation.