前言¶
在 DSH 智能体工作流里,处理编码、哈希和 UUID 是常见操作:读取 API 响应里的 base64 字段、构造 query 参数、校验 sha256 摘要、生成 UUID。把这些操作放进 shell 外部命令,会引入进程调度和命令拼接成本。
omdsh-dev/dsh-tool-encoding 是 DSH 编码/哈希工具插件,提供 UTF-8 文本的 base64/base64url/url/hex 编解码、哈希和 UUID 操作。它定位为零依赖、零进程、纯函数。
这是什么¶
- 仓库:
omdsh-dev/dsh-tool-encoding - 维护者:
omdsh-dev - 许可证:MIT
- 适配版本:DSH 0.1.2-alpha.2(npm)
- 核心定位:给 DSH Agent 提供一组文本编码、哈希和 UUID 工具,覆盖常见 base64/base64url/url/hex 场景。
核心功能¶
下面介绍已核实的操作。所有 action 都按 UTF-8 文本处理,输出为字符串;输入上限 1 MB,输出上限 4 MB(字节)。
| action | 能力 | 示例 |
|---|---|---|
base64_encode / base64_decode |
RFC 4648 标准 base64,严格校验 | foobar → Zm9vYmFy |
base64url_encode / base64url_decode |
JWT 风格 base64url,输出无 padding;解码兼容 +/ 与可选 padding |
U+FEFF → 77u_ |
url_encode / url_decode |
component 语义:空格编码为 %20,不是 +;!'()* 不转义 |
a b → a%20b |
hex_encode / hex_decode |
UTF-8 字节 hex;解码结果必须合法 UTF-8 | AB → 4142 |
hash |
md5/sha1/sha256/sha512 hex 摘要 | sha256 空字符串 → e3b0c442... |
uuid |
UUID v4 字符串,使用 crypto.randomUUID() |
550e8400-... |
校验行为包括:
- base64 输入执行 RFC 4648 canonical 校验
- UTF-8 解码使用 fatal 模式
- 孤立 surrogate 统一拒绝
hex_decode的结果必须是合法 UTF-8hash算法白名单为md5、sha1、sha256、sha512
安装与启用¶
先安装到 web profile:
dsh plugin --profile web add github:omdsh-dev/dsh-tool-encoding
经过上面的步骤,可以做配置检查:
dsh --profile web --dump-config | grep tool-encoding
如果要在 dsh run 中验证,注意 web 与 headless 是不同 profile,dsh run 默认使用 headless profile,因此该 profile 也需要单独安装。本次已核实资料给出的安装命令示例是 web profile;运行验证命令如下:
dsh run "使用 encoding 工具把 hello 做 base64 编码"
典型用法¶
可以在 DSH 会话里选择对应 action:
1、Base64:选择 base64_encode,输入 foobar,得到 Zm9vYmFy。
2、Base64URL:选择 base64url_encode,输入 U+FEFF,得到 77u_。
3、URL component:选择 url_encode,输入 a b,得到 a%20b。
4、Hex:选择 hex_encode,输入 AB,得到 4142。
5、哈希:选择 hash,使用 sha256,输入空字符串,得到 e3b0c442...。
6、UUID:选择 uuid,返回类似 550e8400-... 的 UUID v4 字符串。
适用场景与注意¶
适合处理 UTF-8 文本编码、摘要校验和 UUID 生成。使用前需要注意:
- 不要对机密材料使用本工具:tool 参数会记录进会话日志
- 插件以当前
dsh进程权限运行,安装前应检查源码与许可证 hash仅摘要,无 HMAC/加盐/密钥派生;MD5/SHA-1 仅兼容性/非安全完整性校验- 任意二进制(不可打印字节)编解码需 v2 的
output: "utf8" | "hex"模式 - URL 是 component 语义;表单编码(空格 →
+)需独立 action(v2) web与headless是不同 profile,安装到web不会自动覆盖headless
结尾¶
dsh-tool-encoding 把 DSH 里高频出现的文本编码、哈希和 UUID 操作收进一组工具,减少外部命令和转义拼接。本次资料未提供目录页地址;GitHub 仓库为:
https://github.com/omdsh-dev/dsh-tool-encoding