摘要计算
计算五种 HMAC,密钥通过 JSON 请求体传入
POST
/hmac公开访问
访问类别:匿名 API,可携带 Token 使用独立额度
请求体
application/jsontext必填- string · 最长:8192 字符
key必填- string · 最长:8192 字符
响应
200 计算结果
application/json
{
"type": "object",
"properties": {
"md5": {
"type": "string",
"minLength": 32,
"maxLength": 32,
"pattern": "^[0-9a-f]+$",
"description": "32 位小写十六进制摘要"
},
"sha1": {
"type": "string",
"minLength": 40,
"maxLength": 40,
"pattern": "^[0-9a-f]+$",
"description": "40 位小写十六进制摘要"
},
"sha256": {
"type": "string",
"minLength": 64,
"maxLength": 64,
"pattern": "^[0-9a-f]+$",
"description": "64 位小写十六进制摘要"
},
"sha384": {
"type": "string",
"minLength": 96,
"maxLength": 96,
"pattern": "^[0-9a-f]+$",
"description": "96 位小写十六进制摘要"
},
"sha512": {
"type": "string",
"minLength": 128,
"maxLength": 128,
"pattern": "^[0-9a-f]+$",
"description": "128 位小写十六进制摘要"
}
},
"required": [
"md5",
"sha1",
"sha256",
"sha384",
"sha512"
]
}400 请求校验或执行失败
application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}401 凭据无效、停用、过期或缺少所需 Token
application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}403 需要管理员 Token
application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}413 请求校验或执行失败
application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}415 请求校验或执行失败
application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}429 请求过于频繁,Retry-After 为建议等待秒数;匿名额度及认证保护在各 Cloudflare 地点近似计数,Token 业务额度使用 D1 原子计数
application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}500 内部执行失败
application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}响应示例
运行命令前,将环境变量 BASE_URL 设置为站点地址。
成功响应
printf '%s' '{"text":"你好 🌍","key":"你好 🌍"}' | curl --silent --show-error -X POST -H 'User-Agent: simpleWebUtils-example/1.1.0' -H 'Content-Type: application/json' -H 'Accept: application/json' "$BASE_URL"'/hmac' --data-binary @-HTTP 200
content-type: application/json
content-encoding: gzip
cache-control: no-store
{
"md5": "2dc4fb030fc398140ea3dc3ff5776970",
"sha1": "db55d2055cfe6f3af0710462cb90c02b67cfeda2",
"sha256": "0b5ebf4821bda6d7125c26f31dd5e95994539c808959f5bf13100806223d3f2c",
"sha384": "744aaa91b22ecb4505b9f5cea1399ce3790075f7937187e28af73659390dd1bc280c62cae4d5819d18a0dbd4602e48f0",
"sha512": "2fd0c161833a197a6ef50f52f049849328087f4d42ee6a826b0f90e768b5655ccf69c3981b114c7038b4cb91911a00dc6a04ed892b2ad5f103f8fcbc5042290d"
}错误示例
printf '%s' '{}' | curl --silent --show-error -X POST -H 'User-Agent: simpleWebUtils-example/1.1.0' -H 'Content-Type: application/json' -H 'Accept: application/json' "$BASE_URL"'/hmac' --data-binary @-HTTP 400
content-type: application/json
content-encoding: gzip
cache-control: no-store
{
"error": {
"code": "INVALID_INPUT",
"message": "参数无效",
"issues": [
{
"location": "body",
"field": "text",
"code": "invalid_type",
"message": "需要 字符串 类型"
},
{
"location": "body",
"field": "key",
"code": "invalid_type",
"message": "需要 字符串 类型"
}
]
}
}在线调试
调用示例
curl -X POST 'https://oit.sh/hmac' \
-H 'Content-Type: application/json' \
--data-raw '{"text":"你好 🌍","key":"你好 🌍"}'响应
等待发送请求
配置上方请求参数后点击「发送请求」查看实时响应
快捷键:Ctrl / ⌘ + Enter