a.java 源代码
package j2;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.lang.reflect.Method;
public class a {
static Method f23246a;
static Method f23247b;
static Object f23248c;
static Method f23249d;
static Method f23250e;
static {
try {
Class<?> cls = Class.forName("android.util.Base64");
Class<?> cls2 = Integer.TYPE;
f23246a = cls.getMethod("encode", byte[].class, cls2);
f23247b = cls.getMethod("decode", byte[].class, cls2);
} catch (ClassNotFoundException | Exception unused) {
}
try {
Class<?> cls3 = Class.forName("org.bouncycastle.util.encoders.Base64Encoder");
f23248c = cls3.newInstance();
Class<?> cls4 = Integer.TYPE;
f23249d = cls3.getMethod("encode", byte[].class, cls4, cls4, OutputStream.class);
f23250e = cls3.getMethod("decode", byte[].class, cls4, cls4, OutputStream.class);
} catch (ClassNotFoundException | Exception unused2) {
}
if (f23246a == null && f23249d == null) {
throw new IllegalStateException("No base64 encoder implementation is available.");
}
}
public static String a(byte[] bArr) {
try {
Method method = f23246a;
if (method != null) {
return new String((byte[]) method.invoke(null, bArr, 2));
}
if (f23249d != null) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
f23249d.invoke(f23248c, bArr, 0, Integer.valueOf(bArr.length), byteArrayOutputStream);
return new String(byteArrayOutputStream.toByteArray());
}
throw new IllegalStateException("No base64 encoder implementation is available.");
} catch (Exception e6) {
throw new IllegalStateException(e6.getClass().getName() + ": " + e6.getMessage());
}
}
}