摘要计算
使用 PBKDF2 派生十六进制密钥
POST
/pbkdf2公开访问curl
使用 crypto.subtle,不回显密码或盐。迭代上限 100000,并占用计算类限流额度。 访问类别:匿名 API,可携带 Token 使用独立额度
请求参数
_formatquery- 响应格式为 json 或 text;_format=svg 返回 JSON。plain 是 text 的别名。未识别的值继续按 Accept 协商。
- string · 可选:json、text
_colorquery- 控制 text 响应的 ANSI 颜色。0、false、off、no 关闭;省略或其他值保留。
- string · 可选:0、false、off、no
请求体
application/jsonpassword必填- string · 最长:1024 字符
salt必填- string · 最短:1 字符 · 最长:256 字符
iterations- integer · 1–100000,默认 1000 · 默认值:1000 · 最小值:1 · 最大值:100000
hash- string · 默认值:"SHA-256" · 可选:SHA-1、SHA-256、SHA-384、SHA-512
bits- integer · 派生位数,8 的倍数,最大 512 · 默认值:256 · 最小值:8 · 最大值:512
响应
200 计算结果
application/json
{
"type": "object",
"properties": {
"hash": {
"type": "string",
"pattern": "^[0-9a-f]+$"
},
"iterations": {
"type": "integer"
},
"bits": {
"type": "integer"
},
"algorithm": {
"type": "string",
"enum": [
"SHA-1",
"SHA-256",
"SHA-384",
"SHA-512"
]
}
},
"required": [
"hash",
"iterations",
"bits",
"algorithm"
]
}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' '{"password":"password","salt":"salt","iterations":1,"hash":"SHA-1","bits":160}' | curl --silent --show-error -X POST -H 'User-Agent: simpleWebUtils-example/2.0.1' -H 'Content-Type: application/json' -H 'Accept: application/json' "$BASE_URL"'/pbkdf2' --data-binary @-HTTP 200
content-type: application/json
content-encoding: gzip
cache-control: no-store
{
"hash": "0c60c80f961f0e71f3a9b524af6012062fe037a6",
"iterations": 1,
"bits": 160,
"algorithm": "SHA-1"
}错误示例
printf '%s' '{}' | curl --silent --show-error -X POST -H 'User-Agent: simpleWebUtils-example/2.0.1' -H 'Content-Type: application/json' -H 'Accept: application/json' "$BASE_URL"'/pbkdf2' --data-binary @-HTTP 400
content-type: application/json
content-encoding: gzip
cache-control: no-store
{
"error": {
"code": "INVALID_INPUT",
"message": "参数无效",
"issues": [
{
"location": "body",
"field": "password",
"code": "invalid_type",
"message": "需要 字符串 类型"
},
{
"location": "body",
"field": "salt",
"code": "invalid_type",
"message": "需要 字符串 类型"
}
]
}
}curl 访问示例
curl、wget、HTTPie 默认得到 text/plain。示例展示纯文本输出。
命令与输出
printf '%s' '{"password":"password","salt":"salt","iterations":1,"hash":"SHA-1","bits":160}' | curl --silent --show-error -X POST -H 'User-Agent: curl/8.7.1' -H 'Content-Type: application/json' "$BASE_URL"'/pbkdf2?_color=0' --data-binary @-HTTP 200 content-type: text/plain; charset=utf-8 content-encoding: gzip cache-control: no-store hash: 0c60c80f961f0e71f3a9b524af6012062fe037a6 iterations: 1 bits: 160 algorithm: SHA-1
在线调试
调用示例
curl -X POST 'https://oit.sh/pbkdf2' \
-H 'Content-Type: application/json' \
--data-raw '{"password":"password","salt":"salt"}'响应
等待发送请求
配置上方请求参数后点击「发送请求」查看实时响应
快捷键:Ctrl / ⌘ + Enter