mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-15 18:37:17 +01:00
270 lines
16 KiB
Java
270 lines
16 KiB
Java
package org.java_websocket.util;
|
|
|
|
import com.amazon.alexa.accessory.internal.bluetooth.GenericAccessProfile;
|
|
import com.bugsnag.android.repackaged.dslplatform.json.JsonWriter;
|
|
import java.io.FilterOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.UnsupportedEncodingException;
|
|
import okio.Buffer$$ExternalSyntheticBUOutline0;
|
|
import okio.Utf8;
|
|
import rx.Single$$ExternalSyntheticBUOutline0;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes11.dex */
|
|
public class Base64 {
|
|
static final /* synthetic */ boolean $assertionsDisabled = false;
|
|
public static final int DO_BREAK_LINES = 8;
|
|
public static final int ENCODE = 1;
|
|
private static final byte EQUALS_SIGN = 61;
|
|
public static final int GZIP = 2;
|
|
private static final int MAX_LINE_LENGTH = 76;
|
|
private static final byte NEW_LINE = 10;
|
|
public static final int NO_OPTIONS = 0;
|
|
public static final int ORDERED = 32;
|
|
private static final String PREFERRED_ENCODING = "US-ASCII";
|
|
public static final int URL_SAFE = 16;
|
|
private static final byte[] _STANDARD_ALPHABET = {65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, GenericAccessProfile.MESH_BEACON, 47};
|
|
private static final byte WHITE_SPACE_ENC = -5;
|
|
private static final byte[] _STANDARD_DECODABET = {-9, -9, -9, -9, -9, -9, -9, -9, -9, WHITE_SPACE_ENC, WHITE_SPACE_ENC, -9, -9, WHITE_SPACE_ENC, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, WHITE_SPACE_ENC, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, 62, -9, -9, -9, Utf8.REPLACEMENT_BYTE, 52, 53, 54, 55, 56, 57, JsonWriter.SEMI, 59, 60, 61, -9, -9, -9, -1, -9, -9, -9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -9, -9, -9, -9, -9, -9, 26, 27, 28, 29, 30, 31, 32, GenericAccessProfile.SERVICE_DATA_128BIT, 34, GenericAccessProfile.LE_SECURE_CONNECTIONS_RANDOM_VALUE, GenericAccessProfile.URI, GenericAccessProfile.INDOOR_POSITIONING, GenericAccessProfile.TRANSPORT_DISCOVERY_DATA, GenericAccessProfile.LE_SUPPORTED_FEATURES, GenericAccessProfile.CHANNEL_MAP_UPDATE_INDICATION, GenericAccessProfile.PB_ADV, GenericAccessProfile.MESH_MESSAGE, GenericAccessProfile.MESH_BEACON, JsonWriter.COMMA, 45, 46, 47, 48, 49, 50, 51, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9};
|
|
private static final byte[] _URL_SAFE_ALPHABET = {65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95};
|
|
private static final byte[] _URL_SAFE_DECODABET = {-9, -9, -9, -9, -9, -9, -9, -9, -9, WHITE_SPACE_ENC, WHITE_SPACE_ENC, -9, -9, WHITE_SPACE_ENC, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, WHITE_SPACE_ENC, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, 62, -9, -9, 52, 53, 54, 55, 56, 57, JsonWriter.SEMI, 59, 60, 61, -9, -9, -9, -1, -9, -9, -9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -9, -9, -9, -9, Utf8.REPLACEMENT_BYTE, -9, 26, 27, 28, 29, 30, 31, 32, GenericAccessProfile.SERVICE_DATA_128BIT, 34, GenericAccessProfile.LE_SECURE_CONNECTIONS_RANDOM_VALUE, GenericAccessProfile.URI, GenericAccessProfile.INDOOR_POSITIONING, GenericAccessProfile.TRANSPORT_DISCOVERY_DATA, GenericAccessProfile.LE_SUPPORTED_FEATURES, GenericAccessProfile.CHANNEL_MAP_UPDATE_INDICATION, GenericAccessProfile.PB_ADV, GenericAccessProfile.MESH_MESSAGE, GenericAccessProfile.MESH_BEACON, JsonWriter.COMMA, 45, 46, 47, 48, 49, 50, 51, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9};
|
|
private static final byte[] _ORDERED_ALPHABET = {45, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 95, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122};
|
|
private static final byte[] _ORDERED_DECODABET = {-9, -9, -9, -9, -9, -9, -9, -9, -9, WHITE_SPACE_ENC, WHITE_SPACE_ENC, -9, -9, WHITE_SPACE_ENC, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, WHITE_SPACE_ENC, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, 0, -9, -9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -9, -9, -9, -1, -9, -9, -9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, GenericAccessProfile.SERVICE_DATA_128BIT, 34, GenericAccessProfile.LE_SECURE_CONNECTIONS_RANDOM_VALUE, GenericAccessProfile.URI, -9, -9, -9, -9, GenericAccessProfile.INDOOR_POSITIONING, -9, GenericAccessProfile.TRANSPORT_DISCOVERY_DATA, GenericAccessProfile.LE_SUPPORTED_FEATURES, GenericAccessProfile.CHANNEL_MAP_UPDATE_INDICATION, GenericAccessProfile.PB_ADV, GenericAccessProfile.MESH_MESSAGE, GenericAccessProfile.MESH_BEACON, JsonWriter.COMMA, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, JsonWriter.SEMI, 59, 60, 61, 62, Utf8.REPLACEMENT_BYTE, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9};
|
|
|
|
private Base64() {
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public static int decode4to3(byte[] bArr, int i, byte[] bArr2, int i2, int i3) {
|
|
int i4;
|
|
int i5;
|
|
if (bArr == null) {
|
|
Single$$ExternalSyntheticBUOutline0.m$3("Source array was null.");
|
|
return 0;
|
|
}
|
|
if (bArr2 == null) {
|
|
Single$$ExternalSyntheticBUOutline0.m$3("Destination array was null.");
|
|
return 0;
|
|
}
|
|
if (i < 0 || (i4 = i + 3) >= bArr.length) {
|
|
Buffer$$ExternalSyntheticBUOutline0.m("Source array with length %d cannot have offset of %d and still process four bytes.", new Object[]{Integer.valueOf(bArr.length), Integer.valueOf(i)});
|
|
return 0;
|
|
}
|
|
if (i2 < 0 || (i5 = i2 + 2) >= bArr2.length) {
|
|
Buffer$$ExternalSyntheticBUOutline0.m("Destination array with length %d cannot have offset of %d and still store three bytes.", new Object[]{Integer.valueOf(bArr2.length), Integer.valueOf(i2)});
|
|
return 0;
|
|
}
|
|
byte[] decodabet = getDecodabet(i3);
|
|
byte b = bArr[i + 2];
|
|
if (b == 61) {
|
|
bArr2[i2] = (byte) ((((decodabet[bArr[i + 1]] & 255) << 12) | ((decodabet[bArr[i]] & 255) << 18)) >>> 16);
|
|
return 1;
|
|
}
|
|
byte b2 = bArr[i4];
|
|
if (b2 == 61) {
|
|
int i6 = ((decodabet[bArr[i + 1]] & 255) << 12) | ((decodabet[bArr[i]] & 255) << 18) | ((decodabet[b] & 255) << 6);
|
|
bArr2[i2] = (byte) (i6 >>> 16);
|
|
bArr2[i2 + 1] = (byte) (i6 >>> 8);
|
|
return 2;
|
|
}
|
|
int i7 = ((decodabet[bArr[i + 1]] & 255) << 12) | ((decodabet[bArr[i]] & 255) << 18) | ((decodabet[b] & 255) << 6) | (decodabet[b2] & 255);
|
|
bArr2[i2] = (byte) (i7 >> 16);
|
|
bArr2[i2 + 1] = (byte) (i7 >> 8);
|
|
bArr2[i5] = (byte) i7;
|
|
return 3;
|
|
}
|
|
|
|
private static byte[] encode3to4(byte[] bArr, int i, int i2, byte[] bArr2, int i3, int i4) {
|
|
byte[] alphabet = getAlphabet(i4);
|
|
int i5 = (i2 > 0 ? (bArr[i] << 24) >>> 8 : 0) | (i2 > 1 ? (bArr[i + 1] << 24) >>> 16 : 0) | (i2 > 2 ? (bArr[i + 2] << 24) >>> 24 : 0);
|
|
if (i2 == 1) {
|
|
bArr2[i3] = alphabet[i5 >>> 18];
|
|
bArr2[i3 + 1] = alphabet[(i5 >>> 12) & 63];
|
|
bArr2[i3 + 2] = 61;
|
|
bArr2[i3 + 3] = 61;
|
|
return bArr2;
|
|
}
|
|
if (i2 == 2) {
|
|
bArr2[i3] = alphabet[i5 >>> 18];
|
|
bArr2[i3 + 1] = alphabet[(i5 >>> 12) & 63];
|
|
bArr2[i3 + 2] = alphabet[(i5 >>> 6) & 63];
|
|
bArr2[i3 + 3] = 61;
|
|
return bArr2;
|
|
}
|
|
if (i2 != 3) {
|
|
return bArr2;
|
|
}
|
|
bArr2[i3] = alphabet[i5 >>> 18];
|
|
bArr2[i3 + 1] = alphabet[(i5 >>> 12) & 63];
|
|
bArr2[i3 + 2] = alphabet[(i5 >>> 6) & 63];
|
|
bArr2[i3 + 3] = alphabet[i5 & 63];
|
|
return bArr2;
|
|
}
|
|
|
|
public static String encodeBytes(byte[] bArr, int i, int i2, int i3) throws IOException {
|
|
byte[] encodeBytesToBytes = encodeBytesToBytes(bArr, i, i2, i3);
|
|
try {
|
|
return new String(encodeBytesToBytes, "US-ASCII");
|
|
} catch (UnsupportedEncodingException unused) {
|
|
return new String(encodeBytesToBytes);
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* JADX WARN: Removed duplicated region for block: B:46:0x0065 A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
|
/* JADX WARN: Removed duplicated region for block: B:52:? A[SYNTHETIC] */
|
|
/* JADX WARN: Removed duplicated region for block: B:53:0x0060 A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
|
/* JADX WARN: Removed duplicated region for block: B:57:0x005b A[EXC_TOP_SPLITTER, SYNTHETIC] */
|
|
/* JADX WARN: Type inference failed for: r4v10 */
|
|
/* JADX WARN: Type inference failed for: r4v11 */
|
|
/* JADX WARN: Type inference failed for: r4v13 */
|
|
/* JADX WARN: Type inference failed for: r4v14, types: [java.io.OutputStream, java.util.zip.GZIPOutputStream] */
|
|
/* JADX WARN: Type inference failed for: r4v15 */
|
|
/* JADX WARN: Type inference failed for: r4v7 */
|
|
/* JADX WARN: Type inference failed for: r4v8 */
|
|
/* JADX WARN: Type inference failed for: r4v9 */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public static byte[] encodeBytesToBytes(byte[] r16, int r17, int r18, int r19) throws java.io.IOException {
|
|
/*
|
|
Method dump skipped, instructions count: 248
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: org.java_websocket.util.Base64.encodeBytesToBytes(byte[], int, int, int):byte[]");
|
|
}
|
|
|
|
private static final byte[] getAlphabet(int i) {
|
|
return (i & 16) == 16 ? _URL_SAFE_ALPHABET : (i & 32) == 32 ? _ORDERED_ALPHABET : _STANDARD_ALPHABET;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public static final byte[] getDecodabet(int i) {
|
|
return (i & 16) == 16 ? _URL_SAFE_DECODABET : (i & 32) == 32 ? _ORDERED_DECODABET : _STANDARD_DECODABET;
|
|
}
|
|
|
|
public static String encodeBytes(byte[] bArr) {
|
|
try {
|
|
return encodeBytes(bArr, 0, bArr.length, 0);
|
|
} catch (IOException unused) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class OutputStream extends FilterOutputStream {
|
|
private byte[] b4;
|
|
private boolean breakLines;
|
|
private byte[] buffer;
|
|
private int bufferLength;
|
|
private byte[] decodabet;
|
|
private boolean encode;
|
|
private int lineLength;
|
|
private int options;
|
|
private int position;
|
|
private boolean suspendEncoding;
|
|
|
|
public OutputStream(java.io.OutputStream outputStream, int i) {
|
|
super(outputStream);
|
|
this.breakLines = (i & 8) != 0;
|
|
boolean z = (i & 1) != 0;
|
|
this.encode = z;
|
|
int i2 = z ? 3 : 4;
|
|
this.bufferLength = i2;
|
|
this.buffer = new byte[i2];
|
|
this.position = 0;
|
|
this.lineLength = 0;
|
|
this.suspendEncoding = false;
|
|
this.b4 = new byte[4];
|
|
this.options = i;
|
|
this.decodabet = Base64.getDecodabet(i);
|
|
}
|
|
|
|
@Override // java.io.FilterOutputStream, java.io.OutputStream, java.io.Closeable, java.lang.AutoCloseable
|
|
public void close() throws IOException {
|
|
flushBase64();
|
|
super.close();
|
|
this.buffer = null;
|
|
((FilterOutputStream) this).out = null;
|
|
}
|
|
|
|
public void flushBase64() throws IOException {
|
|
int i = this.position;
|
|
if (i > 0) {
|
|
if (!this.encode) {
|
|
Buffer$$ExternalSyntheticBUOutline0.m$2("Base64 input not properly padded.");
|
|
} else {
|
|
((FilterOutputStream) this).out.write(Base64.encode3to4(this.b4, this.buffer, i, this.options));
|
|
this.position = 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // java.io.FilterOutputStream, java.io.OutputStream
|
|
public void write(int i) throws IOException {
|
|
if (this.suspendEncoding) {
|
|
((FilterOutputStream) this).out.write(i);
|
|
return;
|
|
}
|
|
if (this.encode) {
|
|
byte[] bArr = this.buffer;
|
|
int i2 = this.position;
|
|
int i3 = i2 + 1;
|
|
this.position = i3;
|
|
bArr[i2] = (byte) i;
|
|
int i4 = this.bufferLength;
|
|
if (i3 >= i4) {
|
|
((FilterOutputStream) this).out.write(Base64.encode3to4(this.b4, bArr, i4, this.options));
|
|
int i5 = this.lineLength + 4;
|
|
this.lineLength = i5;
|
|
if (this.breakLines && i5 >= 76) {
|
|
((FilterOutputStream) this).out.write(10);
|
|
this.lineLength = 0;
|
|
}
|
|
this.position = 0;
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
byte b = this.decodabet[i & 127];
|
|
if (b <= -5) {
|
|
if (b == -5) {
|
|
return;
|
|
}
|
|
Buffer$$ExternalSyntheticBUOutline0.m$2("Invalid character in Base64 data.");
|
|
return;
|
|
}
|
|
byte[] bArr2 = this.buffer;
|
|
int i6 = this.position;
|
|
int i7 = i6 + 1;
|
|
this.position = i7;
|
|
bArr2[i6] = (byte) i;
|
|
if (i7 >= this.bufferLength) {
|
|
((FilterOutputStream) this).out.write(this.b4, 0, Base64.decode4to3(bArr2, 0, this.b4, 0, this.options));
|
|
this.position = 0;
|
|
}
|
|
}
|
|
|
|
public OutputStream(java.io.OutputStream outputStream) {
|
|
this(outputStream, 1);
|
|
}
|
|
|
|
@Override // java.io.FilterOutputStream, java.io.OutputStream
|
|
public void write(byte[] bArr, int i, int i2) throws IOException {
|
|
if (this.suspendEncoding) {
|
|
((FilterOutputStream) this).out.write(bArr, i, i2);
|
|
return;
|
|
}
|
|
for (int i3 = 0; i3 < i2; i3++) {
|
|
write(bArr[i + i3]);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public static byte[] encode3to4(byte[] bArr, byte[] bArr2, int i, int i2) {
|
|
encode3to4(bArr2, 0, i, bArr, 0, i2);
|
|
return bArr;
|
|
}
|
|
}
|