public class WxCryptUtil extends Object
对公众平台发送给公众账号的消息加解密示例代码. Copyright (c) 1998-2014 Tencent Inc. 针对org.apache.commons.codec.binary.Base64, 需要导入架包commons-codec-1.9(或commons-codec-1.8等其他版本) 官方下载地址:http://commons.apache.org/proper/commons-codec/download_codec.cgi
| 限定符和类型 | 字段和说明 |
|---|---|
protected byte[] |
aesKey |
protected String |
appidOrCorpid |
protected String |
token |
| 构造器和说明 |
|---|
WxCryptUtil() |
WxCryptUtil(String token,
String encodingAesKey,
String appidOrCorpid)
构造函数.
|
protected byte[] aesKey
protected String token
protected String appidOrCorpid
public String encrypt(String plainText)
plainText - 公众平台待回复用户的消息,xml格式的字符串public String encrypt(String randomStr, String plainText)
plainText - 需要加密的明文public String decrypt(String msgSignature, String timeStamp, String nonce, String encryptedXml)
msgSignature - 签名串,对应URL参数的msg_signaturetimeStamp - 时间戳,对应URL参数的timestampnonce - 随机串,对应URL参数的nonceencryptedXml - 密文,对应POST请求的数据Copyright © 2021. All rights reserved.