Bugly bugs fix
This commit is contained in:
@@ -78,7 +78,7 @@ public final class RxNetManager {
|
||||
.connectTimeout(connectTimeout > 0 ? connectTimeout : DEFAULT_CONNECT_TIME_OUT, TimeUnit.MILLISECONDS)
|
||||
.addNetworkInterceptor(mCacheManager.getHttpCacheInterceptor())
|
||||
.cache(cache != null ? cache : mCacheManager.getCache())
|
||||
.connectionPool(new ConnectionPool(10, 2, TimeUnit.SECONDS))
|
||||
.connectionPool(new ConnectionPool(10, 5, TimeUnit.MINUTES))
|
||||
|
||||
;
|
||||
// 无代理设置,防止被抓包
|
||||
|
@@ -3,8 +3,7 @@ package com.yizhuan.xchat_android_library.utils.codec;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.MappedByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.io.InputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
@@ -26,22 +25,32 @@ public class MD5Utils {
|
||||
if (file == null || !file.exists()) {
|
||||
return null;
|
||||
}
|
||||
String md5 = null;
|
||||
FileInputStream in = new FileInputStream(file);
|
||||
FileChannel ch = in.getChannel();
|
||||
MappedByteBuffer byteBuffer = ch.map(FileChannel.MapMode.READ_ONLY, 0,
|
||||
file.length());
|
||||
InputStream fis = new FileInputStream(file);
|
||||
byte[] buffer = new byte[2048];
|
||||
int numRead = 0;
|
||||
MessageDigest md5;
|
||||
try {
|
||||
|
||||
MessageDigest messagedigest = MessageDigest.getInstance("MD5");
|
||||
messagedigest.update(byteBuffer);
|
||||
md5 = bufferToHex(messagedigest.digest());
|
||||
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
md5 = MessageDigest.getInstance("MD5");
|
||||
while ((numRead = fis.read(buffer)) > 0) {
|
||||
md5.update(buffer, 0, numRead);
|
||||
}
|
||||
fis.close();
|
||||
return md5ToString(md5.digest());
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
return md5;
|
||||
}
|
||||
|
||||
public static String md5ToString(byte[] md5Bytes) {
|
||||
StringBuilder hexValue = new StringBuilder();
|
||||
for (byte md5Byte : md5Bytes) {
|
||||
int val = ((int) md5Byte) & 0xff;
|
||||
if (val < 16) {
|
||||
hexValue.append("0");
|
||||
}
|
||||
hexValue.append(Integer.toHexString(val));
|
||||
}
|
||||
return hexValue.toString();
|
||||
}
|
||||
|
||||
public static String getMD5String(String s) {
|
||||
@@ -58,7 +67,7 @@ public class MD5Utils {
|
||||
String md5 = null;
|
||||
try {
|
||||
|
||||
MessageDigest messagedigest = MessageDigest.getInstance("MD5");
|
||||
MessageDigest messagedigest = MessageDigest.getInstance("MD5");
|
||||
messagedigest.update(bytes);
|
||||
md5 = bufferToHex(messagedigest.digest());
|
||||
|
||||
|
Reference in New Issue
Block a user