Class WeComCrypto
java.lang.Object
io.agentscope.extensions.channel.wecom.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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionDecrypts theEncryptbody and returns the inner XML payload as a UTF-8 string.booleanverifySignature(String signature, String timestamp, String nonce, String encrypt) Verifies the SHA-1 signature produced by sorting[token, timestamp, nonce, encrypt], concatenating, and hashing.
-
Constructor Details
-
WeComCrypto
-
-
Method Details
-
verifySignature
Verifies the SHA-1 signature produced by sorting[token, timestamp, nonce, encrypt], concatenating, and hashing. -
decrypt
Decrypts theEncryptbody and returns the inner XML payload as a UTF-8 string.WeCom plaintext layout after AES-CBC decrypt + PKCS#7 unpad:
| 16 bytes random | 4 bytes msg_len (big-endian) | msg (XML, msg_len bytes) | receive_id |
-