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 .cp .util .crypto ;
23
2
3
+ import com .google .common .base .CharMatcher ;
4
+ import com .google .common .io .BaseEncoding ;
24
5
import me .chanjar .weixin .common .util .crypto .WxCryptUtil ;
25
6
import me .chanjar .weixin .cp .config .WxCpConfigStorage ;
26
- import org .apache .commons .codec .binary .Base64 ;
27
7
28
8
public class WxCpCryptUtil extends WxCryptUtil {
29
-
30
- /**
31
- * 构造函数
32
- *
33
- * @param wxCpConfigStorage
34
- */
35
9
public WxCpCryptUtil (WxCpConfigStorage wxCpConfigStorage ) {
36
10
/*
37
11
* @param token 公众平台上,开发者设置的token
@@ -44,8 +18,7 @@ public WxCpCryptUtil(WxCpConfigStorage wxCpConfigStorage) {
44
18
45
19
this .token = token ;
46
20
this .appidOrCorpid = corpId ;
47
- this .aesKey = Base64 . decodeBase64 ( encodingAesKey + "=" );
21
+ this .aesKey = BaseEncoding . base64 (). decode ( CharMatcher . whitespace (). removeFrom ( encodingAesKey ) );
48
22
}
49
23
50
-
51
24
}
0 commit comments