Bencode 编码器/解码器
将 bencode(BitTorrent .torrent 文件使用的编码格式)解码为 JSON,或将 JSON 编码为 bencode — 解码 torrent 文件字典时提供 torrent 信息摘要。
输入
Drop a file or browse
One file · any type
输出
结果
Torrent 信息
| 属性 | 值 |
|---|---|
| No data yet | |
这对您有帮助吗?
使用指南
什么是 bencode?
Bencode("B-encode")是 BitTorrent 使用的数据序列化格式 — 这是 .torrent 文件和跟踪器响应编码整数、字节串、列表和字典的方式。它比 JSON 更简单(没有空格、没有浮点数、字典键必须是字符串并且已排序),但用途相同:以紧凑、明确的方式表示结构化数据。
此工具如何工作
在两种模式之间切换:
- 解码 (Bencode → JSON) — 粘贴原始 bencode 文本(或上传
.torrent文件)并获得可读的 JSON。不是有效 UTF-8 文本的二进制数据表示为带有hex:前缀的十六进制字符串,因为 JSON 无法保存原始字节。 - 编码 (JSON → Bencode) — 粘贴 JSON 并获得其 bencode 表示形式。字典键按字母顺序排序,符合规范的 bencode 编码规则。
如果解码的数据看起来像 torrent 文件(具有 announce URL、info 字典等),Torrent 信息表会总结跟踪器、名称、分片长度、文件列表和总大小。
Bencode 的四种类型
- 整数:
i42e→42(任意大小 — 此工具在内部使用BigInt,因此超大整数不会无声地失去精度,对于超过Number.MAX_SAFE_INTEGER的值回退到字符串) - 字节字符串:
5:hello→"hello"(长度前缀,无引号) - 列表:
l4:spam4:eggse→["spam", "eggs"] - 字典:
d3:cow3:mooe→{"cow": "moo"}(键必须是字符串,编码时排序)
常见用途
- 在没有 BitTorrent 客户端的情况下检查
.torrent文件的内容 - 调试生成或使用 bencode 的服务
- 将结构化数据转换为 bencode 以用于 BitTorrent 相邻协议
- 通过并排查看 JSON 来学习 bencode 格式
隐私
此工具完全在您的浏览器中运行。您的数据永远不会上传到服务器。
bencodetorrentbittorrentjsonencoderdecoder
Use it from code
From 3 credits per callREST API
curl -X POST https://api.iotools.cloud/v1/tool/bencode-encoder-decoder \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"mode": "decode",
"inputText": "d8:announce35:http://tracker.example.com/announc…",
"jsonInput": ""
}'Swap in your own key from your account. The tool's fields are the body — no wrapper.
Ask an AI agent
Use the IOTools `bencode-encoder-decoder` tool (Bencode Encoder/Decoder) on this input:
YOUR_INPUT_HEREPaste this at any agent connected to the IOTools MCP server, then add your input.