|
1 |
| -/** |
2 |
| - * 对公众平台发送给公众账号的消息加解密示例代码. |
3 |
| - * |
4 |
| - * @copyright Copyright (c) 1998-2014 Tencent Inc. |
5 |
| - * <p> |
6 |
| - * 针对org.apache.commons.codec.binary.Base64, |
7 |
| - * 需要导入架包commons-codec-1.9(或commons-codec-1.8等其他版本) |
8 |
| - * 官方下载地址:http://commons.apache.org/proper/commons-codec/download_codec.cgi |
9 |
| - * <p> |
10 |
| - * 针对org.apache.commons.codec.binary.Base64, |
11 |
| - * 需要导入架包commons-codec-1.9(或commons-codec-1.8等其他版本) |
12 |
| - * 官方下载地址:http://commons.apache.org/proper/commons-codec/download_codec.cgi |
13 |
| - */ |
14 |
| - |
15 |
| -// ------------------------------------------------------------------------ |
16 |
| - |
17 |
| -/** |
18 |
| - * 针对org.apache.commons.codec.binary.Base64, |
19 |
| - * 需要导入架包commons-codec-1.9(或commons-codec-1.8等其他版本) |
20 |
| - * 官方下载地址:http://commons.apache.org/proper/commons-codec/download_codec.cgi |
21 |
| - */ |
22 | 1 | package me.chanjar.weixin.common.util.crypto;
|
23 | 2 |
|
24 | 3 | import org.apache.commons.codec.binary.Base64;
|
|
37 | 16 | import java.util.Arrays;
|
38 | 17 | import java.util.Random;
|
39 | 18 |
|
| 19 | +/** |
| 20 | + * 对公众平台发送给公众账号的消息加解密示例代码. |
| 21 | + * |
| 22 | + * @copyright Copyright (c) 1998-2014 Tencent Inc. |
| 23 | + * 针对org.apache.commons.codec.binary.Base64, |
| 24 | + * 需要导入架包commons-codec-1.9(或commons-codec-1.8等其他版本) |
| 25 | + * 官方下载地址:http://commons.apache.org/proper/commons-codec/download_codec.cgi |
| 26 | + */ |
40 | 27 | public class WxCryptUtil {
|
41 | 28 |
|
42 | 29 | private static final Base64 base64 = new Base64();
|
@@ -64,9 +51,9 @@ public WxCryptUtil() {
|
64 | 51 | /**
|
65 | 52 | * 构造函数
|
66 | 53 | *
|
67 |
| - * @param token 公众平台上,开发者设置的token |
68 |
| - * @param encodingAesKey 公众平台上,开发者设置的EncodingAESKey |
69 |
| - * @param appidOrCorpid 公众平台appid/corpid |
| 54 | + * @param token 公众平台上,开发者设置的token |
| 55 | + * @param encodingAesKey 公众平台上,开发者设置的EncodingAESKey |
| 56 | + * @param appidOrCorpid 公众平台appid/corpid |
70 | 57 | */
|
71 | 58 | public WxCryptUtil(String token, String encodingAesKey,
|
72 | 59 | String appidOrCorpid) {
|
@@ -231,8 +218,7 @@ protected String encrypt(String randomStr, String plainText) {
|
231 | 218 | * @param encryptedXml 密文,对应POST请求的数据
|
232 | 219 | * @return 解密后的原文
|
233 | 220 | */
|
234 |
| - public String decrypt(String msgSignature, String timeStamp, String nonce, |
235 |
| - String encryptedXml) { |
| 221 | + public String decrypt(String msgSignature, String timeStamp, String nonce, String encryptedXml) { |
236 | 222 | // 密钥,公众账号的app corpSecret
|
237 | 223 | // 提取密文
|
238 | 224 | String cipherText = extractEncryptPart(encryptedXml);
|
|
0 commit comments