npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

n8n-nodes-sm2-crypto

v1.0.14

Published

SM2 encryption and decryption node for n8n

Downloads

29

Readme

n8n SM2 密码学节点

Contributors Forks Stargazers Issues MIT License

目录

关于项目

这是一个专为 n8n 工作流自动化平台开发的社区节点,提供了完整的 SM2 密码学功能集成。

SM2 是基于椭圆曲线的公钥密码算法,是中国国家密码标准(GM/T 0003-2012)的一部分。通过此节点,你可以在 n8n 工作流中无缝集成 SM2 加密和解密功能,确保数据传输的安全性。

核心功能

  • 🔐 国密 SM2 算法:基于官方 sm-crypto 库,提供标准的 SM2 加密解密
  • 🚀 高性能处理:支持大文本和二进制数据的快速加密解密
  • 📊 灵活配置:支持自定义字段名称和数据格式
  • 🎯 易于集成:符合 n8n 标准,开箱即用
  • 🛡️ 安全可靠:严格遵循国密标准,确保加密安全性
  • 💡 智能错误处理:友好的错误提示和异常处理

技术栈

  • n8n 框架n8n-workflow
  • 密码学库sm-crypto
  • 开发语言:TypeScript
  • 构建工具:Gulp + TypeScript
  • 代码规范:ESLint + Prettier

快速开始

环境要求

  • n8n 版本:>= 1.0.0
  • Node.js 版本:>= 20.15
  • 已测试版本:n8n 1.x

安装步骤

  1. 通过 n8n 社区节点安装

    按照 n8n 社区节点安装指南 进行操作。

  2. 通过 npm 安装

    npm install n8n-nodes-sm2-crypto
  3. 重启 n8n 服务

    # 如果使用 npm 安装的 n8n
    n8n start
       
    # 如果使用 Docker
    docker restart n8n
  4. 验证安装

    在 n8n 编辑器中搜索 "SM2 Crypto" 节点,应该能看到新增的节点。

项目结构

├── /nodes/                    # n8n 节点实现
│  └── /Sm2Crypto/            # SM2 密码学节点
│     ├── Sm2Crypto.node.ts   # 主节点实现
│     └── sm2-crypto.svg      # 节点图标
├── /dist/                     # 编译输出目录
├── .eslintrc.js              # ESLint 配置
├── .prettierrc.js            # Prettier 配置
├── gulpfile.js               # Gulp 构建配置
├── package.json              # 项目依赖和脚本
├── tsconfig.json             # TypeScript 配置
└── README.md                 # 项目文档

使用指南

支持的操作

| 操作 | 描述 | 用途场景 | |------------|------------------------------------|------------------------------| | 加密 | 使用 SM2 公钥加密明文数据 | 数据保护、安全传输 | | 解密 | 使用 SM2 私钥解密密文 | 数据解密、信息恢复 |

操作详细说明

🔒 加密操作

  • 令牌(密钥):SM2 公钥(64位十六进制格式,不含 '04' 前缀)
  • 输入字段名称:包含待加密数据的属性名称(默认:data
// 输入示例
{
  "data": "Hello, World!",
  "publicKey": "7b93a5e9d8c4f2a1b6e3c7d9f4a2b8e1c5d6f9a2b4e7c1d8f3a6b9c2e5d7f8a1"
}

🔓 解密操作

  • 令牌(密钥):SM2 私钥(64位十六进制格式)
  • 输入字段名称:包含待解密数据的属性名称(默认:data
// 输入示例  
{
  "data": "04a1b2c3d4e5f6...",
  "privateKey": "3f2a1b4c5e6d7f8a9b2c3d4e5f6a7b8c9d2e3f4a5b6c7d8e9f1a2b3c4d5e6f7"
}

使用示例

场景一:敏感数据加密

HTTP请求节点 → 数据处理 → SM2加密 → 数据库存储

场景二:数据解密处理

数据库查询 → SM2解密 → 数据处理 → API响应

场景三:文件安全传输

文件读取 → SM2加密 → 文件传输 → SM2解密 → 文件处理

输出格式

加密输出:

{
  "data": "Hello, World!",
  "ciphertext": "04a1b2c3d4e5f6..."
}

解密输出:

{
  "data": "04a1b2c3d4e5f6...",
  "plaintext": "Hello, World!"
}

错误输出:

{
  "data": "invalid data",
  "error": "Invalid key format"
}

密钥格式要求

  • 公钥:64字符十六进制字符串(未压缩格式,不含 '04' 前缀)
  • 私钥:64字符十六进制字符串

开发命令

构建和开发

  • npm run build - 完整构建(TypeScript 编译 + 图标复制)
  • npm run dev - 开发模式,TypeScript 监听模式
  • npm run format - 使用 Prettier 格式化代码
  • npm run lint - 运行 ESLint 检查
  • npm run lintfix - 自动修复 ESLint 问题

代码质量

  • npm run prepublishOnly - 发布前检查(构建 + lint)
  • npm run publicPublish - 发布到 npm(公开访问)

发布

# 发布新版本
npm version patch|minor|major
npm run publicPublish

部署选项

本地开发环境

  1. 克隆项目

    git clone https://github.com/felix-liuyj/n8n-nodes-sm2-crypto.git
    cd n8n-nodes-sm2-crypto
  2. 安装依赖

    npm install
  3. 开发模式

    npm run dev
  4. 链接到本地 n8n

    # 创建全局链接
    npm link
       
    # 在 n8n 项目中链接
    cd /path/to/n8n
    npm link n8n-nodes-sm2-crypto

生产环境部署

  1. 通过 npm 安装

    npm install n8n-nodes-sm2-crypto
  2. Docker 环境中安装

    FROM n8nio/n8n:latest
    RUN npm install n8n-nodes-sm2-crypto
  3. 通过 n8n 社区节点管理器

    • 在 n8n 界面中安装社区节点
    • 搜索 "n8n-nodes-sm2-crypto"
    • 点击安装并重启 n8n

配置参数

节点参数

加密操作

| 参数名 | 类型 | 必填 | 描述 | 默认值 | |---------------|---------|------|-------------------------|--------| | token | string | ✅ | SM2 公钥(十六进制) | - | | inputFieldName| string | ❌ | 输入数据字段名 | data |

解密操作

| 参数名 | 类型 | 必填 | 描述 | 默认值 | |---------------|---------|------|-------------------------|--------| | token | string | ✅ | SM2 私钥(十六进制) | - | | inputFieldName| string | ❌ | 输入数据字段名 | data |

兼容性

| 环境要求 | 最低版本 | 推荐版本 | 测试版本 | |---------------|------------|------------|-------------| | n8n | 1.0.0 | 最新版本 | 1.x | | Node.js | 20.15 | 20.x LTS | 20.15+ | | TypeScript | 5.0 | 5.8+ | 5.8.2 |

开发贡献

欢迎参与项目开发!请遵循以下步骤:

  1. Fork 项目
  2. 创建功能分支 (git checkout -b feature/AmazingFeature)
  3. 提交更改 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 创建 Pull Request

开发环境搭建

# 克隆项目
git clone https://github.com/felix-liuyj/n8n-nodes-sm2-crypto.git
cd n8n-nodes-sm2-crypto

# 安装依赖
npm install

# 开发模式
npm run dev

# 构建项目
npm run build

# 代码检查
npm run lint

许可证

本项目基于 MIT 许可证开源。详细信息请查看 LICENSE.md 文件。

联系方式

作者:Felix Liu (Cambria Tech)
邮箱[email protected]
项目链接https://github.com/felix-liuyj/n8n-nodes-sm2-crypto


相关资源