what-the-bank/sources/org/bouncycastle/util/encoders/UrlBase64.java

59 lines
2.2 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.util.encoders;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/* loaded from: classes6.dex */
public class UrlBase64 {
private static final Encoder encoder = new UrlBase64Encoder();
public static byte[] encode(byte[] bArr) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
encoder.encode(bArr, 0, bArr.length, byteArrayOutputStream);
return byteArrayOutputStream.toByteArray();
} catch (Exception e) {
StringBuilder sb = new StringBuilder("exception encoding URL safe base64 data: ");
sb.append(e.getMessage());
throw new EncoderException(sb.toString(), e);
}
}
public static int encode(byte[] bArr, OutputStream outputStream) throws IOException {
return encoder.encode(bArr, 0, bArr.length, outputStream);
}
public static byte[] decode(byte[] bArr) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
encoder.decode(bArr, 0, bArr.length, byteArrayOutputStream);
return byteArrayOutputStream.toByteArray();
} catch (Exception e) {
StringBuilder sb = new StringBuilder("exception decoding URL safe base64 string: ");
sb.append(e.getMessage());
throw new DecoderException(sb.toString(), e);
}
}
public static byte[] decode(String str) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
encoder.decode(str, byteArrayOutputStream);
return byteArrayOutputStream.toByteArray();
} catch (Exception e) {
StringBuilder sb = new StringBuilder("exception decoding URL safe base64 string: ");
sb.append(e.getMessage());
throw new DecoderException(sb.toString(), e);
}
}
public static int decode(byte[] bArr, OutputStream outputStream) throws IOException {
return encoder.decode(bArr, 0, bArr.length, outputStream);
}
public static int decode(String str, OutputStream outputStream) throws IOException {
return encoder.decode(str, outputStream);
}
}