AS AgentScopeAPI 手册 / API Reference

FeishuCrypto

public final class FeishuCrypto
源码Source io/agentscope/extensions/channel/feishu/FeishuCrypto.java:43–138

Feishu Crypto,把智能体接入外部消息渠道与企业平台。位于 io.agentscope.extensions.channel.feishu 包。核心成员包括 verifySignature、decrypt、FeishuCrypto。

Implements Feishu callback encryption + signature verification.

Feishu encrypts the callback body when an Encrypt Key is configured in the developer console. The wire format is JSON {"encrypt":"<base64-ciphertext>"}. The AES key is derived as SHA-256(encryptKey) (32 bytes). The ciphertext layout is:


| 16 bytes IV | AES-CBC + PKCS#7 padded body |

The signature header X-Lark-Signature is computed as SHA-256(timestamp + nonce + encryptKey + rawBody) where rawBody is the raw HTTP request body (the JSON-stringified envelope, not the decrypted plaintext).

构造器摘要Constructor Summary

构造器Constructor说明Description
public FeishuCrypto(String encryptKey)
初始化 `FeishuCrypto` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public boolean verifySignature(String signature, String timestamp, String nonce, String body)
执行 `verifySignature` 方法。
Verifies the SHA-256 signature: `hex(SHA-256(timestamp + nonce + encryptKey + body))`.
public String decrypt(String encryptBase64)
设置该参数。
Decrypts the `encrypt` string from a Feishu callback.

构造器详情Constructor Detail

FeishuCrypto

public FeishuCrypto(String encryptKey)

初始化 FeishuCrypto 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
encryptKeyStringencrypt 键(类型 `String`)。The encrypt key.
源码Source io/agentscope/extensions/channel/feishu/FeishuCrypto.java:48–59

方法详情Method Detail

verifySignature

public boolean verifySignature(String signature, String timestamp, String nonce, String body)

执行 verifySignature 方法。

Verifies the SHA-256 signature: hex(SHA-256(timestamp + nonce + encryptKey + body)).

参数Parameters
名称Name类型Type说明Description
signatureStringsignature(类型 `String`)。The signature.
timestampString时间戳(类型 `String`)。The timestamp.
nonceStringnonce(类型 `String`)。The nonce.
bodyString正文(类型 `String`)。The body.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/extensions/channel/feishu/FeishuCrypto.java:65–84

decrypt

public String decrypt(String encryptBase64)

设置该参数。

Decrypts the encrypt string from a Feishu callback.

参数Parameters
名称Name类型Type说明Description
encryptBase64Stringencrypt 基类 64(类型 `String`)。The encrypt base 64.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/channel/feishu/FeishuCrypto.java:96–115
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.