package com.company;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.security.MessageDigest;
public class Main {
private static final char[] DIGITS_UPPER = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
public static void main(String[] args) {
String str="room_id=6911880153266785031&hold_living_room=1&is_login=0&enter_from_uid_by_shared=0&scenario=0&enter_source=live_merge-live_cover&live_reason=rec&request_id&202012301214310102040482284F014D6B&enter_type=draw";
byte[] sb=str.getBytes();
String result=md5Hex(sb);
System.out.println(result);
}
public static String md5Hex(byte[] bArr) {
try {
return new String(encodeHex(MessageDigest.getInstance("MD5").digest(bArr), DIGITS_UPPER));
} catch (Throwable unused) {
return null;
}
}
private static char[] encodeHex(byte[] bArr, char[] cArr) {
int length = bArr.length;
char[] cArr2 = new char[(length << 1)];
int i = 0;
for (int i2 = 0; i2 < length; i2++) {
int i3 = i + 1;
cArr2[i] = cArr[(bArr[i2] & -16) >>> 4];
i = i3 + 1;
cArr2[i3] = cArr[bArr[i2] & 15];
}
return cArr2;
}
}
打印结果null 我的猜测是抛出异常返回null 但是为啥呢?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…