fix: StandardCharsets.UTF_8 替换为 Charset.forName("UTF-8")
Android 4.2(API 17)不支持 java.nio.charset.StandardCharsets(API 19+), 5 个文件统一改用兼容 API 1 的 String 重载: - DeviceIdentityProvider / HMacShaUtils / Md5Utils: Charset.forName - UrlParamBuilder: URLEncoder.encode(str, "UTF-8") - ContentDetailUtils: 删除未使用的 import
This commit is contained in:
@@ -9,7 +9,7 @@ import com.pukka.jiecheng.config.AppConfiguration;
|
||||
import com.pukka.libcore.boxShared.BoxSharedParamsUtils;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -87,7 +87,7 @@ public class DeviceIdentityProvider {
|
||||
return "";
|
||||
}
|
||||
MessageDigest digest = MessageDigest.getInstance("MD5");
|
||||
byte[] hashBytes = digest.digest(source.getBytes(StandardCharsets.UTF_8));
|
||||
byte[] hashBytes = digest.digest(source.getBytes(Charset.forName("UTF-8")));
|
||||
int usedBytes = Math.min(MD5_TRUNCATED_BYTES, hashBytes.length);
|
||||
if (usedBytes <= 0) {
|
||||
return "";
|
||||
@@ -112,7 +112,7 @@ public class DeviceIdentityProvider {
|
||||
return "";
|
||||
}
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||
byte[] hashBytes = digest.digest(source.getBytes(StandardCharsets.UTF_8));
|
||||
byte[] hashBytes = digest.digest(source.getBytes(Charset.forName("UTF-8")));
|
||||
StringBuilder hexBuilder = new StringBuilder(hashBytes.length * 2);
|
||||
for (byte hashByte : hashBytes) {
|
||||
hexBuilder.append(String.format(Locale.ROOT, "%02X", hashByte));
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.pukka.jiecheng.utils;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Map;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class UrlParamBuilder {
|
||||
|
||||
@@ -60,9 +60,15 @@ public class UrlParamBuilder {
|
||||
urlBuilder.append("&");
|
||||
}
|
||||
|
||||
urlBuilder.append(URLEncoder.encode(entry.getKey(), StandardCharsets.UTF_8))
|
||||
try {
|
||||
urlBuilder.append(URLEncoder.encode(entry.getKey(), "UTF-8"))
|
||||
.append("=")
|
||||
.append(URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8));
|
||||
.append(URLEncoder.encode(entry.getValue(), "UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
urlBuilder.append(entry.getKey())
|
||||
.append("=")
|
||||
.append(entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.pukka.jiecheng.R;
|
||||
import com.pukka.libcore.fresco.PkSimpleDraweeView;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
11
day.code-workspace
Normal file
11
day.code-workspace
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "../../Desktop/tv.huashi.jetsenx.jetsenfilx.jsttvday/day"
|
||||
},
|
||||
{
|
||||
"path": "."
|
||||
}
|
||||
],
|
||||
"settings": {}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.pukka.libcore.cipher;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class HMacShaUtils {
|
||||
SecretKeySpec signingKey = new SecretKeySpec(key.getBytes(), HMAC_SHA256_ALGORITHM);
|
||||
Mac mac = Mac.getInstance(HMAC_SHA256_ALGORITHM);
|
||||
mac.init(signingKey);
|
||||
return mac.doFinal(data.getBytes(StandardCharsets.UTF_8));
|
||||
return mac.doFinal(data.getBytes(Charset.forName("UTF-8")));
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvalidKeyException e) {
|
||||
@@ -51,7 +51,7 @@ public class HMacShaUtils {
|
||||
SecretKeySpec signingKey = new SecretKeySpec(key.getBytes(), HMAC_SHA1_ALGORITHM);
|
||||
Mac mac = Mac.getInstance(HMAC_SHA1_ALGORITHM);
|
||||
mac.init(signingKey);
|
||||
return mac.doFinal(data.getBytes(StandardCharsets.UTF_8));
|
||||
return mac.doFinal(data.getBytes(Charset.forName("UTF-8")));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.pukka.libcore.cipher;
|
||||
|
||||
import com.pukka.libcore.utils.ByteConversionUtils;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.MessageDigest;
|
||||
|
||||
/**
|
||||
@@ -61,7 +61,7 @@ public class Md5Utils {
|
||||
public static String encrypt(String message) {
|
||||
String md5str = "";
|
||||
try {
|
||||
md5str = encrypt(message.getBytes(StandardCharsets.UTF_8));
|
||||
md5str = encrypt(message.getBytes(Charset.forName("UTF-8")));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user