# Text Hash Calculator

> Computes the MD5 (RFC 1321), SHA-1 (RFC 3174), SHA-256 (FIPS 180-4) and CRC-32 (IEEE 802.3 polynomial) digests of a text encoded as UTF-8, plus its byte length; all algorithms are implemented in plain JavaScript.

- Calculator id: `text-hash` · Category: Developer & IT (`developer`) · Tool name: `calculate_text_hash`
- Canonical page: https://tttkmbb.com/developer/text-hash · This document: https://tttkmbb.com/developer/text-hash.md · JSON definition: https://tttkmbb.com/developer/text-hash.json

## Purpose

Computes the MD5 (RFC 1321), SHA-1 (RFC 3174), SHA-256 (FIPS 180-4) and CRC-32 (IEEE 802.3 polynomial) digests of a text encoded as UTF-8, plus its byte length; all algorithms are implemented in plain JavaScript.

**Use when:** You need a checksum or digest of a short text to compare with a published value, generate a cache key or verify a test vector.

**Do not use when:** You need to hash a file or binary data, a keyed MAC (HMAC), a password hash (use bcrypt/scrypt/Argon2), or a hash of more than 200,000 characters.

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `text` | string |  | required | The text to hash; it is encoded as UTF-8 without a trailing newline (echo -n). |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `md5` | string |  | 128-bit MD5 digest, 32 lower-case hex characters (broken for collision resistance; checksums only). |
| `sha1` | string |  | 160-bit SHA-1 digest, 40 hex characters (deprecated for signatures). |
| `sha256` | string |  | 256-bit SHA-256 digest, 64 hex characters. |
| `crc32` | string |  | CRC-32 (polynomial 0xEDB88320, as in zlib, PNG and Ethernet), 8 hex characters. |
| `crc32_decimal` | integer |  | The same CRC-32 as an unsigned integer. |
| `byte_length` | integer | bytes | Length of the UTF-8 encoding that was hashed. |
| `character_count` | integer |  | Number of Unicode code points in the text. |

## Formula

`digest = H(UTF-8(text)) for H ∈ {MD5, SHA-1, SHA-256}; CRC-32 = reflected CRC with polynomial 0x04C11DB7 (0xEDB88320 reversed), initial value 0xFFFFFFFF, final XOR 0xFFFFFFFF`

Reference implementations of RFC 1321, RFC 3174 and FIPS 180-4 on 32-bit words; results match sha256sum / md5sum of the same bytes without a newline. The empty string cannot be submitted (its digests are d41d8cd9…, da39a3ee…, e3b0c442…).

## Data Sources

- RFC 1321 – The MD5 Message-Digest Algorithm — https://www.rfc-editor.org/rfc/rfc1321 (standard, retrieved 2026-09-24)
- RFC 3174 – US Secure Hash Algorithm 1 (SHA1) — https://www.rfc-editor.org/rfc/rfc3174 (standard, retrieved 2026-09-24)
- NIST FIPS 180-4 – Secure Hash Standard (SHS) — https://csrc.nist.gov/pubs/fips/180-4/upd1/final (standard, retrieved 2026-09-24)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/text-hash?text=…`
- `POST https://tttkmbb.com/api/v1/calculate/text-hash` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/text-hash · OpenAPI operationId `calculate_text_hash` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool:  `run_calculator` with `{"calculator_id": "text-hash", "inputs": {…}}`

## Example

- hello: inputs `{"text":"hello"}` → `{"md5":"5d41402abc4b2a76b9719d911017c592","sha1":"aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d","sha256":"2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824","crc32":"3610a686","byte_length":5}`
- The quick brown fox jumps over the lazy dog: inputs `{"text":"The quick brown fox jumps over the lazy dog"}` → `{"md5":"9e107d9d372bb6826bd81d3542a419d6","sha1":"2fd4e1c67a2d28fced849ee1bb76e7391b93eb12","sha256":"d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592","crc32":"414fa339","byte_length":43}`

```
GET https://tttkmbb.com/api/v1/calculate/text-hash?text=hello
```

## Limitations

You need to hash a file or binary data, a keyed MAC (HMAC), a password hash (use bcrypt/scrypt/Argon2), or a hash of more than 200,000 characters. Reference implementations of RFC 1321, RFC 3174 and FIPS 180-4 on 32-bit words; results match sha256sum / md5sum of the same bytes without a newline. The empty string cannot be submitted (its digests are d41d8cd9…, da39a3ee…, e3b0c442…). All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**Why does my result differ from echo text | md5sum?**

echo appends a newline, so the shell hashes one extra byte. Use echo -n or printf '%s' to hash the bare text.

**Which hash should I use?**

SHA-256 for integrity and signatures. MD5 and SHA-1 are cryptographically broken (collisions can be manufactured) and CRC-32 detects accidental corruption only.

**How are non-ASCII characters handled?**

The text is encoded as UTF-8 first, so 'é' contributes 2 bytes and an emoji 4; byte_length reports the encoded size.

## Related

- [Base64 Size Calculator](https://tttkmbb.com/developer/base64-size.md) — Size of the same data once Base64-encoded.
- [Password Entropy Calculator](https://tttkmbb.com/everyday/password-entropy.md) — Strength of a secret rather than its digest.
- [Number Base Converter](https://tttkmbb.com/math/base-converter.md) — Read hex digests as decimal or binary.
