package com.huawei.hms.common.util; import android.util.Base64; import com.huawei.hms.support.log.HMSLog; /* loaded from: classes2.dex */ public final class Base64Utils { public static String encode(byte[] bArr) { if (bArr != null) { return Base64.encodeToString(bArr, 0); } return null; } public static String encodeUrlSafe(byte[] bArr) { if (bArr != null) { return Base64.encodeToString(bArr, 10); } return null; } public static String encodeUrlSafeNoPadding(byte[] bArr) { if (bArr != null) { return Base64.encodeToString(bArr, 11); } return null; } public static byte[] decode(String str) { byte[] bArr = new byte[0]; if (str != null) { try { return Base64.decode(str, 0); } catch (IllegalArgumentException e) { StringBuilder sb = new StringBuilder("decode failed : "); sb.append(e.getMessage()); HMSLog.e("Base64Utils", sb.toString()); } } return bArr; } public static byte[] decodeUrlSafe(String str) { byte[] bArr = new byte[0]; if (str != null) { try { return Base64.decode(str, 10); } catch (IllegalArgumentException e) { StringBuilder sb = new StringBuilder("decodeUrlSafe failed : "); sb.append(e.getMessage()); HMSLog.e("Base64Utils", sb.toString()); } } return bArr; } public static byte[] decodeUrlSafeNoPadding(String str) { byte[] bArr = new byte[0]; if (str != null) { try { return Base64.decode(str, 11); } catch (IllegalArgumentException e) { StringBuilder sb = new StringBuilder("decodeUrlSafeNoPadding failed : "); sb.append(e.getMessage()); HMSLog.e("Base64Utils", sb.toString()); } } return bArr; } }