humanhash.dev
为十六进制摘要起一个易记的名字。
将 f3527e4ef32f… 变成 canyon-jam-telescope-creek。一个小巧、免费的 REST API,适用于 SHA-1、SHA-256、MD5、UUID,以及任何可以编码为 hex 的内容。
试一下
对任意 hex 摘要发起 GET 请求 /api/v1/hash/<hex>。端点开放、确定性、支持 CORS:
https://humanhash.dev/api/v1/hash/f3527e4ef32f9d8b59ead6b7b70a843c3da1c105响应:
{
"inputHash": "f3527e4ef32f9d8b59ead6b7b70a843c3da1c105",
"hash": "canyon-jam-telescope-creek"
} 工作原理
HumanHash 通过三步将任意十六进制字符串映射为一个简短、可朗读的名称:
- 解析 将 hex 输入解析为字节数组。
- 压缩 将这些字节分成 N 个等长段(默认 N = 4),对每段做 XOR 压缩为单个字节。
- 映射 将每个结果字节(0–255)映射到精选 256 词列表中的一个,然后用连字符连接。
输出完全确定——相同输入始终产生相同名称——算法无状态,不涉及数据库或随机性。从 256 词列表中取 4 个词,可得 256⁴ ≈ 43 亿种组合,约为 32 位指纹:足以让人识别单次部署或构建,但若需抗碰撞性,不能替代底层哈希。
API 参考
GET https://humanhash.dev/api/v1/hash/{hex}
- 路径参数
-
hex— 任何十六进制字符串。无长度限制;较长输入会在映射前做 XOR 压缩。 - 响应
- JSON:
{ "inputHash": string, "hash": string } - 单词
- 始终为 4 个用连字符分隔的单词,来自固定的 256 词列表。
- 认证
- 无。CORS 开放。
- 速率限制
- 尽力而为,无硬性限制。高强度使用请自托管或内嵌算法。
代码示例
curl
curl https://humanhash.dev/api/v1/hash/f3527e4ef32f9d8b59ead6b7b70a843c3da1c105 JavaScript (fetch)
const hex = "f3527e4ef32f9d8b59ead6b7b70a843c3da1c105";
const res = await fetch(`https://humanhash.dev/api/v1/hash/${hex}`);
const { hash } = await res.json();
console.log(hash); // "canyon-jam-telescope-creek" Python
import requests
hex_digest = "f3527e4ef32f9d8b59ead6b7b70a843c3da1c105"
r = requests.get(f"https://humanhash.dev/api/v1/hash/{hex_digest}")
print(r.json()["hash"]) # "canyon-jam-telescope-creek" Go
resp, _ := http.Get("https://humanhash.dev/api/v1/hash/f3527e4ef32f9d8b59ead6b7b70a843c3da1c105")
defer resp.Body.Close()
var out struct{ InputHash, Hash string }
json.NewDecoder(resp.Body).Decode(&out)
fmt.Println(out.Hash) // "canyon-jam-telescope-creek" UUID
UUID 也可以——先去掉连字符:
curl https://humanhash.dev/api/v1/hash/550e8400e29b41d4a716446655440000
# => {"inputHash":"550e8400e29b41d4a716446655440000","hash":"vault-lift-onion-lilac"} 示例:GitHub Actions
一种常见做法是根据 github.sha 派生一个易记名称,与 SHA 并用——例如用两者同时打 Docker 镜像标签。我们在自己的生产流水线中就是这样使用 HumanHash 的:
name: build
on:
push:
branches: ["main"]
env:
IMAGE_NAME: "ghcr.io/your-org/your-app"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get human hash
run: echo "HUMAN_HASH=$(curl -s "https://humanhash.dev/api/v1/hash/${{ github.sha }}" | jq -r '.hash')" >> "$GITHUB_ENV"
- name: Build Docker image
run: docker build . --tag ${{ env.IMAGE_NAME }}:${{ github.sha }} --tag ${{ env.IMAGE_NAME }}:${{ env.HUMAN_HASH }}
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image
run: docker push --all-tags ${{ env.IMAGE_NAME }} 每次 push 都会得到两个标签:用于可复现的精确 SHA,以及一个像 swift-river-mellow-bolt 这样在聊天、看板和站会中真正可用的友好名称。 jq 命令已预装在 GitHub 托管的 ubuntu-latest runner 上,无需额外配置。
使用场景
- 构建和部署名称。 把 CI 构建标记为 swift-river-mellow-bolt 而不是 7c4f9a2,更易在站会中提及,也更易在聊天记录中查找。
- 聊天中的 commit 引用。 在 Slack 中粘贴 SHA 会被忽略;粘贴 canyon-jam-telescope-creek 才会被读到。
- 日志中的会话和请求 ID。 跨服务 grep 或在电话会议中口述 ID 时,单词远胜 hex。
- 备份和快照名称。 恢复 vault-bronze-falcon-river 比恢复 b8f9c1d2… 让人安心得多。
- 指纹比对。 用四个单词比对 SSH 或 TLS 指纹,比 40 个 hex 字符快得多。
- 资产/版本标签。 给构建产物、模型检查点或数据快照起一个可以被人讨论的名字。
与其他标识符格式对比
| 格式 | 示例 | 易记 | 碰撞空间 |
|---|---|---|---|
| SHA-1 hex | f3527e4ef32f… | 否 | 2¹⁶⁰ |
| UUID v4 | 550e8400-e29b-41d4-a716-… | 否 | 2¹²² |
| Base58 (12 字符) | 5KQwrPbwdL5M | 一般 | ~70 位 |
| HumanHash (4 词) | canyon-jam-telescope-creek | 是 | 2³² ≈ 43 亿 |
| Petname / coolname 库 | quiet-blue-finch | 是 | 不定 |
HumanHash 的独特之处在于它是已有标识符的确定性投影——它不替代你的 UUID 或哈希,而是用人能读的名字与之并列。两者搭配使用。
常见问题
什么是 HumanHash? +
算法是如何工作的? +
转换可逆吗? +
可以用于安全令牌或身份验证吗? +
API 是免费的吗?有速率限制吗? +
可以自托管或内嵌算法吗? +
总共有多少种唯一输出? +
谁在运营 humanhash.dev? +
256 词词表
输出取自一份精选的 256 个简短、可朗读英文单词列表,按主题分为八组,每组 32 个。该列表避开拼写歧义、近同音词以及串联后不易朗读的词。
颜色 (32)
aqua, azure, beige, bronze, brown, cherry, coral, cream, cyan, gold, grey, hazel, indigo, ivory, jade, khaki, lemon, lilac, lime, magenta, maroon, mauve, olive, peach, pink, plum, ruby, sage, sand, teal, violet, white
动物 (32)
alpaca, badger, beaver, bison, cobra, crane, deer, dingo, eagle, falcon, ferret, fox, geese, heron, jaguar, koala, kookaburra, lemur, lynx, moth, otter, panda, pelican, quail, raven, shark, sloth, swan, tiger, trout, vulture, zebra
行星与太空 (32)
asteroid, comet, cosmos, crater, eclipse, galaxy, halo, jupiter, mars, mercury, meteor, nebula, neptune, orbit, planet, quasar, rocket, satellite, saturn, sky, solar, space, star, sun, telescope, terra, titan, universe, uranus, venus, vortex, zenith
自然与地理 (32)
bluff, cairn, canyon, coast, creek, desert, dune, forest, glacier, grove, hill, horizon, island, jungle, knoll, lake, meadow, moss, ocean, peak, puddle, ridge, river, stream, swamp, thistle, trail, valley, volcano, wave, woods, yarrow
食物与水果 (32)
apple, berry, bread, cake, clove, cookie, dough, grape, herb, honey, jam, juice, kiwi, maize, melon, mint, muffin, noodle, oats, onion, pesto, pickle, pie, rind, roast, spice, sugar, toast, vanilla, waffle, yeast, zest
形容词 (32)
agile, brave, calm, clever, crisp, daring, deep, easy, fierce, flat, giant, great, happy, heavy, high, light, lively, loud, lucky, mellow, quick, quiet, rapid, ready, sharp, silent, smart, smooth, solid, swift, vast, vivid
物件与概念 (32)
anchor, beacon, bolt, bridge, canvas, cipher, clock, coin, crown, diamond, echo, flare, ghost, glyph, hammer, helix, jewel, key, ledger, locket, maze, moment, needle, puzzle, quill, scroll, shield, signal, spirit, token, tower, vault
动词与动作 (32)
bounce, capture, dash, drift, enter, escape, fly, glide, grasp, halt, jump, launch, lift, march, move, pedal, plunge, quiver, race, roam, scan, seek, shine, soar, spin, spring, steer, stride, thrust, touch, travel, weave
无保证
本服务按现状提供,不提供可用性保证,也不承诺永远存在。话虽如此,我们将其用于自己的生产负载,所以在可预见的未来不会消失。如果你依赖它,请考虑将算法内嵌——它很小。
关于
HumanHash 由 Pilvia Oy运营,一家芬兰云公司。我们在内部用它来标注构建、部署和快照,并因算法的通用价值将其开放。
humanhash 概念最初是 Zachary Voase 的一个小型 Python 库。本实现是运行在 Cloudflare Workers 上的独立 TypeScript 重写,并配以我们自己的词表。