public class WXBizMsgCrypt extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
(专用程序包) byte[] |
aesKey |
(专用程序包) org.apache.commons.codec.binary.Base64 |
base64 |
(专用程序包) static Charset |
CHARSET |
(专用程序包) String |
receiveid |
(专用程序包) String |
token |
| 构造器和说明 |
|---|
WXBizMsgCrypt(String token,
String encodingAesKey,
String receiveId)
构造函数
|
| 限定符和类型 | 方法和说明 |
|---|---|
(专用程序包) String |
decrypt(String text)
对密文进行解密.
|
String |
DecryptMsg(String msgSignature,
String timeStamp,
String nonce,
String postData)
检验消息的真实性,并且获取解密后的明文.
|
(专用程序包) String |
encrypt(String randomStr,
String text)
对明文进行加密.
|
String |
EncryptMsg(String replyMsg,
String timeStamp,
String nonce)
将企业微信回复用户的消息加密打包.
|
(专用程序包) byte[] |
getNetworkBytesOrder(int sourceNumber) |
(专用程序包) String |
getRandomStr() |
(专用程序包) int |
recoverNetworkBytesOrder(byte[] orderBytes) |
String |
VerifyURL(String msgSignature,
String timeStamp,
String nonce,
String echoStr)
验证URL
|
static Charset CHARSET
org.apache.commons.codec.binary.Base64 base64
byte[] aesKey
String token
String receiveid
public WXBizMsgCrypt(String token, String encodingAesKey, String receiveId) throws AesException
token - 企业微信后台,开发者设置的tokenencodingAesKey - 企业微信后台,开发者设置的EncodingAESKeyreceiveId, - 不同场景含义不同,详见文档AesException - 执行失败,请查看该异常的错误码和具体的错误信息byte[] getNetworkBytesOrder(int sourceNumber)
int recoverNetworkBytesOrder(byte[] orderBytes)
String getRandomStr()
String encrypt(String randomStr, String text) throws AesException
text - 需要加密的明文AesException - aes加密失败String decrypt(String text) throws AesException
text - 需要解密的密文AesException - aes解密失败public String EncryptMsg(String replyMsg, String timeStamp, String nonce) throws AesException
replyMsg - 企业微信待回复用户的消息,xml格式的字符串timeStamp - 时间戳,可以自己生成,也可以用URL参数的timestampnonce - 随机串,可以自己生成,也可以用URL参数的nonceAesException - 执行失败,请查看该异常的错误码和具体的错误信息public String DecryptMsg(String msgSignature, String timeStamp, String nonce, String postData) throws AesException
msgSignature - 签名串,对应URL参数的msg_signaturetimeStamp - 时间戳,对应URL参数的timestampnonce - 随机串,对应URL参数的noncepostData - 密文,对应POST请求的数据AesException - 执行失败,请查看该异常的错误码和具体的错误信息public String VerifyURL(String msgSignature, String timeStamp, String nonce, String echoStr) throws AesException
msgSignature - 签名串,对应URL参数的msg_signaturetimeStamp - 时间戳,对应URL参数的timestampnonce - 随机串,对应URL参数的nonceechoStr - 随机串,对应URL参数的echostrAesException - 执行失败,请查看该异常的错误码和具体的错误信息Copyright © 2024. All rights reserved.