Skip to content

Commit

Permalink
fix: 解决中文乱码问题
Browse files Browse the repository at this point in the history
  • Loading branch information
renfei committed Dec 22, 2020
1 parent e890346 commit fd9b641
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
<dependency>
<groupId>net.renfei</groupId>
<artifactId>discuz-ucenter-api-for-java</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</dependency>
```

如果你使用的是传统方式,需要下载```Jar```包,放入```lib```文件夹,下载地址:[discuz-ucenter-api-for-java-1.0.0.jar
](https://github.com/renfei/discuz-ucenter-api-for-java/releases/download/1.0.0/discuz-ucenter-api-for-java-1.0.0.jar)
如果你使用的是传统方式,需要下载```Jar```包,放入```lib```文件夹,下载地址:[discuz-ucenter-api-for-java-1.0.1.jar
](https://github.com/renfei/discuz-ucenter-api-for-java/releases/download/1.0.1/discuz-ucenter-api-for-java-1.0.1.jar)

## 使用

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>net.renfei</groupId>
<artifactId>discuz-ucenter-api-for-java</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
<packaging>jar</packaging>
<name>discuz-ucenter-api-for-java</name>
<url>https://github.com/renfei/discuz-ucenter-api-for-java</url>
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/net/renfei/discuz/ucenter/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.net.MalformedURLException;
import java.net.Socket;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
Expand Down Expand Up @@ -275,9 +276,14 @@ public String ucAuthcode(String string, String operation, String key, int expiry
}

if (operation.equals("DECODE")) {
String result = result1.substring(0, result1.length());
if ((Integer.parseInt(substr(result.toString(), 0, 10)) == 0 || Long.parseLong(substr(result.toString(), 0, 10)) - time() > 0) && substr(result.toString(), 10, 16).equals(substr(md5(substr(result.toString(), 26) + keyb), 0, 16))) {
return substr(result.toString(), 26);
String result= result1.toString();
try{
result=new String(result.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
}catch (Exception e) {
result = result1.substring(0, result1.length());
}
if ((Integer.parseInt(substr(result, 0, 10)) == 0 || Long.parseLong(substr(result, 0, 10)) - time() > 0) && substr(result, 10, 16).equals(substr(md5(substr(result, 26) + keyb), 0, 16))) {
return substr(result, 26);
} else {
return "";
}
Expand Down

0 comments on commit fd9b641

Please sign in to comment.