# hash/v1 — Hashing endpoint

Computes a cryptographic or checksum digest of an input, using Go's
standard library (`crypto/md5`, `crypto/sha1`, `crypto/sha256`,
`crypto/sha512`, `hash/crc32`). Purely deterministic — the point is that an
LLM cannot compute a hash by reasoning about it and will guess a
plausible-looking but wrong hex string; this endpoint returns the actual
value.

### `POST /v1/hash/digest`

**Request**

```json
{ "algo": "sha256", "input": "hello", "encoding": "text" }
```

- `algo` (required) — one of `md5`, `sha1`, `sha256`, `sha512`, `crc32`.
- `input` (required) — the data to hash, encoded per `encoding`.
- `encoding` (optional, default `"text"`) — how `input` is encoded:
  - `"text"` — `input` is used as-is (UTF-8 bytes).
  - `"base64"` — `input` is standard-alphabet base64, decoded before hashing.
  - `"hex"` — `input` is a hex string, decoded before hashing.

**Response**

```json
{ "algo": "sha256", "digest": "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824" }
```

The digest is always a lowercase hex string. `crc32` produces a 32-bit
value formatted as 8 hex characters, same convention as the other
algorithms.

**Error response**

```json
{ "error": "unsupported algorithm \"foo\": expected one of md5, sha1, sha256, sha512, crc32" }
```

**Example**

```bash
curl -s -X POST https://apished.com/v1/hash/digest \
  -H 'Content-Type: application/json' \
  -d '{"algo": "sha256", "input": "hello"}'
# {"algo":"sha256","digest":"2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"}
```

## Known test vectors

Useful for verifying a client independently against this endpoint:

| algo   | input         | digest |
|--------|---------------|--------|
| md5    | `""`          | `d41d8cd98f00b204e9800998ecf8427e` |
| sha1   | `""`          | `da39a3ee5e6b4b0d3255bfef95601890afd80709` |
| sha256 | `""`          | `e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855` |
| sha512 | `""`          | `cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e` |
| crc32  | `"123456789"` | `cbf43926` |

## Out of scope

HMAC/keyed variants and password hashing (bcrypt/argon2) — different use
case (secrets, not identifiers).

## Files

- `hash.go` — module wiring (routes, HTTP handlers)
- `digest.go` — pure hashing logic
- `digest_test.go` — known-vector and encoding tests
