Hash text
hash_textCompute a cryptographic digest or keyed HMAC of any text. Supports MD5, SHA-1, SHA-256, SHA-384, SHA-512 with hex, base64, or base64url output, and includes constant-time verification.
Instructions
Computes a cryptographic digest (or keyed HMAC) of a string. Supports md5, sha1, sha256, sha384, and sha512 with hex, base64, or base64url output. Can also verify the result against an expected digest using a constant-time comparison.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | No | If provided, computes an HMAC keyed by this secret instead of a plain digest. | |
| text | Yes | The text to hash, interpreted as UTF-8. | |
| encoding | No | How to encode the digest bytes. | hex |
| expected | No | An expected digest to compare against, using a constant-time comparison. | |
| algorithm | No | Digest algorithm. md5 and sha1 are provided for interoperability only. | sha256 |