Skip to content

Commit

Permalink
修复decryptUserInfo中文乱码问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Akimizu1994 committed Dec 17, 2018
1 parent 5603e36 commit 5bc59cb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/weixin/popular/util/WxaUtil.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package weixin.popular.util;

import java.nio.charset.StandardCharsets;
import java.security.Key;

import javax.crypto.Cipher;
Expand Down Expand Up @@ -44,7 +45,7 @@ public static WxaDUserInfo decryptUserInfo(String session_key, String encryptedD
Key sKeySpec = new SecretKeySpec(Base64.decodeBase64(session_key), "AES");
cipher.init(Cipher.DECRYPT_MODE, sKeySpec, new IvParameterSpec(Base64.decodeBase64(iv)));
byte[] resultByte = cipher.doFinal(Base64.decodeBase64(encryptedData));
String data = new String(PKCS7Encoder.decode(resultByte));
String data = new String(PKCS7Encoder.decode(resultByte), StandardCharsets.UTF_8);
return JsonUtil.parseObject(data, WxaDUserInfo.class);
} catch (Exception e) {
logger.error("", e);
Expand Down

0 comments on commit 5bc59cb

Please sign in to comment.