package com.tencent.smtt.utils; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Md5Utils { /* JADX WARNING: Removed duplicated region for block: B:27:0x003d A[SYNTHETIC, Splitter:B:27:0x003d] */ /* JADX WARNING: Removed duplicated region for block: B:34:0x0048 A[SYNTHETIC, Splitter:B:34:0x0048] */ /* JADX WARNING: Removed duplicated region for block: B:41:0x0053 A[SYNTHETIC, Splitter:B:41:0x0053] */ public static String getMD5(File file) { FileInputStream fileInputStream; Throwable th; MessageDigest messageDigest; FileInputStream fileInputStream2 = null; try { messageDigest = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { try { e.printStackTrace(); messageDigest = null; } catch (FileNotFoundException unused) { fileInputStream = null; if (fileInputStream != null) { try { fileInputStream.close(); } catch (IOException e2) { e2.printStackTrace(); } } return null; } catch (IOException unused2) { fileInputStream = null; if (fileInputStream != null) { try { fileInputStream.close(); } catch (IOException e3) { e3.printStackTrace(); } } return null; } catch (Throwable th2) { th = th2; if (fileInputStream2 != null) { try { fileInputStream2.close(); } catch (IOException e4) { e4.printStackTrace(); } } throw th; } } fileInputStream = new FileInputStream(file); try { byte[] bArr = new byte[8192]; while (true) { int read = fileInputStream.read(bArr); if (read == -1) { break; } messageDigest.update(bArr, 0, read); } String a = ByteUtils.a(messageDigest.digest()); try { fileInputStream.close(); } catch (IOException e5) { e5.printStackTrace(); } return a; } catch (FileNotFoundException unused3) { if (fileInputStream != null) { } return null; } catch (IOException unused4) { if (fileInputStream != null) { } return null; } catch (Throwable th3) { th = th3; fileInputStream2 = fileInputStream; if (fileInputStream2 != null) { } throw th; } } public static String getMD5(String str) { if (str == null) { return null; } try { byte[] bytes = str.getBytes(); MessageDigest instance = MessageDigest.getInstance("MD5"); instance.update(bytes); return ByteUtils.a(instance.digest()); } catch (Exception unused) { return null; } } public static byte[] getMD5(InputStream inputStream) { if (inputStream == null) { return null; } try { MessageDigest instance = MessageDigest.getInstance("MD5"); if (instance == null) { return null; } byte[] bArr = new byte[8192]; while (true) { int read = inputStream.read(bArr); if (read == -1) { return instance.digest(); } instance.update(bArr, 0, read); } } catch (Throwable unused) { return null; } } public static byte[] getMD5(byte[] bArr) { try { MessageDigest instance = MessageDigest.getInstance("MD5"); instance.update(bArr); return instance.digest(); } catch (Exception unused) { return null; } } }