Hash Data
使用 SHA/MD5 对数据进行哈希。
计算值的十六进制 SHA-256、SHA-384 或 SHA-512 摘要。字符串按 UTF-8 计算;其他值先序列化为 JSON。
工作原理
- 解析配置;在
data中使用纯表达式,例如{{ $json.email }}。 - 当
data为 undefined、null 或空字符串时,以data is required从error输出。 - 校验
algorithm(默认sha256)是否为sha256、sha384或sha512。 - 非字符串值用
JSON.stringify序列化,再对 UTF-8 文本计算摘要。 - 从
out返回{ hash }(小写十六进制),并附带meta.crypto。
在工作流中
节点在工作流文件(draft_nodes[])中的写法,以及一次成功运行的 envelope。
{
"node_id": "node-hash-email",
"label": "Hash customer email",
"operator_slug": "crypto.hash",
"operator_version": "2.0.0",
"config": {
"data": "{{ $json.email }}",
"algorithm": "sha256"
}
}{
"ok": true,
"port": "out",
"data": {
"hash": "8c87b489ce35cf2e2f39f80e282cb2e804932a56a213983eeeb428407d43b52d"
},
"meta": {
"crypto": {
"op": "hash",
"key_source": null,
"alias": null,
"credential_id": null,
"algorithm": "sha256",
"ok": true
}
}
}配置
-
dataany 必填 -
Data to hash (objects are JSON-serialized)
-
algorithmstring 可选
代码中的行为
除 schema 描述之外,实现代码对这些键的实际处理。
-
data - 对象通过
JSON.stringify序列化,键的顺序会影响结果:{"a":1,"b":2}与{"b":2,"a":1}的摘要不同。跨系统比较摘要时,请先规范化该值。
输出端口
out 默认 摘要已计算。
数据
{
"hash": "8c87b489ce35cf2e2f39f80e282cb2e804932a56a213983eeeb428407d43b52d"
}error 缺少 data,或算法不受支持。
数据
{
"error": "Unsupported hash algorithm: md5"
}在表达式中
后续节点可通过 $("Hash Data").item.json.<路径> 读取此节点输出中的内容(请把 Hash Data 换成你的节点标签)。Editor 标记工作流编辑器在 Previous Nodes 中提示的路径(输出契约);Worker 标记 worker 实际通过 out 返回的路径,依据“端口”一节所示的输出。
| 表达式 | Editor | Worker |
|---|---|---|
$("Hash Data").item.json.hashHex 编码 |
错误
| 消息 | 端口 | 原因与处理 |
|---|---|---|
data is required | error | data 为空,或其表达式未解析出任何值。0 和 false 是合法值。 |
Unsupported hash algorithm: <algorithm> | error | 仅支持 sha256、sha384 和 sha512。 |
输入契约
-
dataany 必填 -
algorithmstring 可选
输出契约
-
hashstring 可选 -
Hex 编码
契约(JSON Schema)
与编排器声明完全一致的定义。All 是完整的 *.definition.js;可与上方各节对照,找出文档与 schema 之间的差异。发布前可用它校验节点。
{
"slug": "crypto.hash",
"name": "Hash Data",
"category": "identity",
"version": "2.0.0",
"description": "Hashes data with SHA-256, SHA-384 or SHA-512 (hex).",
"capabilities": [
"crypto",
"hash"
],
"config_schema": {
"type": "object",
"properties": {
"data": {
"description": "Data to hash (objects are JSON-serialized)"
},
"algorithm": {
"type": "string",
"default": "sha256",
"enum": [
"sha256",
"sha384",
"sha512"
]
}
},
"required": [
"data"
]
},
"input_contract_schema": {
"type": "object",
"properties": {
"data": {},
"algorithm": {
"type": "string"
}
},
"required": [
"data"
]
},
"output_contract_schema": {
"type": "object",
"properties": {
"hash": {
"type": "string"
}
}
},
"ports": [
{
"port_id": "out",
"label": "Hash",
"description": "Hashed string",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Hash failed",
"is_default": false,
"supports_condition": false
}
],
"execution_mode": "sync",
"required_resources": [],
"compatible_worker_pools": [
"standard"
],
"tags": [
"crypto",
"security"
],
"is_stateful": false,
"publisher": {
"identity": "org_veripass",
"profile": {
"name": "Veripass",
"verified": true,
"url": "https://me.veripass.com/veripass",
"logo_url": null
}
}
}{
"type": "object",
"properties": {
"data": {
"description": "Data to hash (objects are JSON-serialized)"
},
"algorithm": {
"type": "string",
"default": "sha256",
"enum": [
"sha256",
"sha384",
"sha512"
]
}
},
"required": [
"data"
]
}{
"type": "object",
"properties": {
"data": {},
"algorithm": {
"type": "string"
}
},
"required": [
"data"
]
}{
"type": "object",
"properties": {
"hash": {
"type": "string"
}
}
}[
{
"port_id": "out",
"label": "Hash",
"description": "Hashed string",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Hash failed",
"is_default": false,
"supports_condition": false
}
]执行
- 执行方式
sync- 有状态
- 否
- 能力
cryptohash- 标签
cryptosecurity
说明与限制
- 该摘要不带密钥:相同输入始终得到相同结果,适合做相等性比较和假名化键。
- 从
error端口输出不会使运行失败:引擎沿error上的连线继续;若没有连线,该分支直接结束。
已对照编排器代码核实 · 31e874b · 2026-11-26