AS AgentScopeAPI 手册 / API Reference

WeComCrypto

public final class WeComCrypto
源码Source io/agentscope/extensions/channel/wecom/WeComCrypto.java:40–166

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

Implements WeCom's URL-handshake signature + AES-CBC + PKCS#7 encrypt / decrypt scheme. See WeCom callback specification.

Inputs:

  • token — the developer-supplied callback token.

  • encodingAesKey — 43-character base64 (no padding). Decoded with appended "=" to yield a 32-byte AES key. The first 16 bytes are also used as the CBC IV.

  • receiveId — the corp id (for self-built apps) or suite id (for ISV apps). Decryption verifies the trailing receive-id against this value.

构造器摘要Constructor Summary

构造器Constructor说明Description
public WeComCrypto(String token, String encodingAesKey, String receiveId)
初始化 `WeComCrypto` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public boolean verifySignature(String signature, String timestamp, String nonce, String encrypt)
执行 `verifySignature` 方法。
Verifies the SHA-1 signature produced by sorting `[token, timestamp, nonce, encrypt]`, concatenating, and hashing.
public String decrypt(String encryptBase64)
设置该参数。
Decrypts the `Encrypt` body and returns the inner XML payload as a UTF-8 string.

构造器详情Constructor Detail

WeComCrypto

public WeComCrypto(String token, String encodingAesKey, String receiveId)

初始化 WeComCrypto 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
tokenString令牌(类型 `String`)。The token.
encodingAesKeyStringencoding Aes 键(类型 `String`)。The encoding aes key.
receiveIdString接收标识(类型 `String`)。The receive id.
源码Source io/agentscope/extensions/channel/wecom/WeComCrypto.java:47–68

方法详情Method Detail

verifySignature

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

执行 verifySignature 方法。

Verifies the SHA-1 signature produced by sorting [token, timestamp, nonce, encrypt], concatenating, and hashing.

参数Parameters
名称Name类型Type说明Description
signatureStringsignature(类型 `String`)。The signature.
timestampString时间戳(类型 `String`)。The timestamp.
nonceStringnonce(类型 `String`)。The nonce.
encryptStringencrypt(类型 `String`)。The encrypt.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/extensions/channel/wecom/WeComCrypto.java:74–96

decrypt

public String decrypt(String encryptBase64)

设置该参数。

Decrypts the Encrypt body and returns the inner XML payload as a UTF-8 string.

参数Parameters
名称Name类型Type说明Description
encryptBase64Stringencrypt 基类 64(类型 `String`)。The encrypt base 64.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/channel/wecom/WeComCrypto.java:107–143
基于官方固定版本源码静态生成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.