Skip to content

omdsh-dev/dsh-tool-encoding

30Last commit Aug 14, 2026

dsh-tool-encoding DSH plugin

This plugin provides a set of encoding and hashing tools for DSH agents. It handles base64, base64url, URL component, and hex encoding/decoding, as well as MD5, SHA1, SHA256, SHA512 hashing and UUID v4 generation. All operations are pure functions with strict validation, zero dependencies, and no subprocess spawning.

How to install the dsh-tool-encoding DSH plugin

dsh plugin --profile web add github:omdsh-dev/dsh-tool-encoding

Copying does not run this command. Review the repository and version before installing the dsh-tool-encoding DSH plugin.

dsh-tool-encoding DSH plugin data source

dsh-tool-encoding DSH plugin snapshot date: Aug 16, 2026

discovered

What the dsh-tool-encoding DSH plugin can do

  • Base64 encoding/decoding with RFC 4648 canonical strict validation (rejects non-canonical unused bits and padding errors).
  • Base64url encoding/decoding (JWT style, no padding, compatible with +/ and optional padding).
  • URL component encoding/decoding (space as %20, not +; preserves !'()*).
  • Hex encoding/decoding of UTF-8 bytes (decoded result must be valid UTF-8).
  • Hash digest (MD5, SHA1, SHA256, SHA512) returning hex strings; for non-security uses only.
  • UUID v4 generation via crypto.randomUUID().

Where the dsh-tool-encoding DSH plugin fits

  • Decode JWT payload base64 fields from API responses.
  • Encode parameters for URL query strings (component semantic).
  • Verify file integrity by computing SHA256 checksum.
  • Generate unique identifiers for distributed systems.
  • Convert binary data to hex representation for logging or debugging.

Who the dsh-tool-encoding DSH plugin is for

  • DSH agent developers who need reliable encoding/hashing without subprocess overhead.
  • Engineers building AI workflows that require inline encoding, hashing, or UUID generation.

dsh-tool-encoding DSH plugin limitations

  • All inputs and outputs are UTF-8 text; binary content must be represented as hex (v2 plans to add output mode).
  • Hash operations only provide digest; no HMAC, salting, or key derivation. MD5/SHA1 are for compatibility only, not security.
  • URL encoding uses component semantics; form encoding (space → +) requires a separate action (planned for v2).
  • Input byte size limited to 1 MB, output to 4 MB (enforced by Buffer.byteLength).
  • Only supports UTF-8 encoding; decoding fails on invalid UTF-8 bytes (fatal mode).

dsh-tool-encoding DSH plugin: from the repository README

Quoted from the omdsh-dev/dsh-tool-encoding README, the upstream source of the dsh-tool-encoding DSH plugin. Copyright remains with the original authors.

DSH 编码/哈希工具插件 —— UTF-8 文本的 base64/base64url/url/hex 编解码 + 哈希 + UUID。零依赖、零进程、纯函数。 > 包名:`@deepseek-ai/dsh-tool-encoding`(独立 bundle,非 monorepo 集成形态);`lib/` 产物由仓库内 `npm run build`(tsc)生成并随仓库提交。 [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) ## 动机 Agent 处理编码/哈希是日常高频操作:查看 API 响应里的 base64 字段(JWT payload)、构造 query 参数、校验文件完整性(sha256)、生成 UUID。当前做法 `bash -c "echo ... | base64"` 的问题:进程开销、**引号转义地狱**(base64 串嵌进 bash 命令再嵌进 JSON 参数,双层转义错误率极高)、跨平台工具命名不一致(`md5` vs `md5sum` vs `shasum -a 256`)。 ## 安全模型 无 `eval`、无 `new Function`。所有操作是 `Buffer`/`node:crypto`/`TextDecoder`/`encodeURIComponent` 的纯函数组合: - **UTF-8 完整性**:解码用 fatal 模式(`TextDecoder('utf-8', { fatal: true })`),非法字节抛 `encoding: invalid UTF-8 output`;合法 U+FFFD/控制字符不误伤(`00` NUL、`0a` 换行、`efbfbd` U+FFFD 均合法,`ff` 非法) - **base64 严格校验**:无空白、`=` 仅末尾且 ≤2、长度必须为 4 的倍数、**RFC 4648 canonical unused bits**(`Zh==` 等非 canonical 编码拒绝,防多串映射同文本) - **孤立 surrogate 统一拒绝**:所有文本输入过 `String.prototype.isWellFormed()`,避免静默替换与 URIError 行为不一致 - **字节上限**:输入 1 MB / 输出 4 MB(各 1,000,000 / 4,000,000 字节,`Buffer.byteLength`;输出上限为分配前预估 + 最终检查的保险丝) - **哈希算法白名单**:`Object.hasOwn` 查表(md5/sha1/sha256/sha512) - 错误统一 `encoding:` 前缀,不透传底层 `URIError`/`TypeEr

Read the full READMERepository license: MIT

dsh-tool-encoding DSH plugin questions

How do I install dsh-tool-encoding plugin?

Use the DSH CLI: `dsh plugin --profile web add github:omdsh-dev/dsh-tool-encoding` for the web profile, or replace `web` with `headless` for headless profile. Alternatively, you can run `npm pack` in the repository and then `dsh plugin --profile web add ./dsh-tool-encoding-*.tgz`. Verify installation with `dsh --profile web --dump-config | grep tool-encoding`.

What hash algorithms are supported?

The plugin supports MD5, SHA1, SHA256, and SHA512. These are intended for non-security uses such as file integrity checks or compatibility. The algorithm is selected via the `algorithm` parameter in the `hash` action.

What happens if I try to decode invalid base64?

The plugin strictly validates base64 per RFC 4648. It rejects whitespace, incorrect padding (padding must be at the end and ≤2 characters, length must be a multiple of 4), and non-canonical unused bits (e.g., `Zh==`). If validation fails, it throws an error with an `encoding:` prefix. All errors are standardized and do not leak underlying exceptions.

Can I generate a UUID with this plugin?

Yes, the plugin provides a `uuid` action that returns a UUID v4 string using `crypto.randomUUID()`. It takes no parameters and returns the UUID as a string. This is useful for generating unique identifiers without spawning a subprocess.

Does URL encoding use + for spaces?

No, the URL encoding uses component semantics, which means spaces are encoded as `%20`, not `+`. The `+` character is preserved as `+` in decode. For form encoding (where spaces become `+`), you would need a separate action (planned for v2).