mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-18 03:47:18 +01:00
253 lines
7.7 KiB
Java
253 lines
7.7 KiB
Java
package org.codehaus.jackson;
|
|
|
|
import com.amazon.alexa.ra.core.ui.markdown.parser.formatter.MarkdownConstants;
|
|
import defpackage.a$$ExternalSyntheticOutline0;
|
|
import java.util.Arrays;
|
|
import rx.Single$$ExternalSyntheticBUOutline0;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes11.dex */
|
|
public final class Base64Variant {
|
|
public static final int BASE64_VALUE_INVALID = -1;
|
|
public static final int BASE64_VALUE_PADDING = -2;
|
|
static final char PADDING_CHAR_NONE = 0;
|
|
private final int[] _asciiToBase64;
|
|
private final byte[] _base64ToAsciiB;
|
|
private final char[] _base64ToAsciiC;
|
|
final int _maxLineLength;
|
|
final String _name;
|
|
final char _paddingChar;
|
|
final boolean _usesPadding;
|
|
|
|
public Base64Variant(String str, String str2, boolean z, char c, int i) {
|
|
int[] iArr = new int[128];
|
|
this._asciiToBase64 = iArr;
|
|
char[] cArr = new char[64];
|
|
this._base64ToAsciiC = cArr;
|
|
this._base64ToAsciiB = new byte[64];
|
|
this._name = str;
|
|
this._usesPadding = z;
|
|
this._paddingChar = c;
|
|
this._maxLineLength = i;
|
|
int length = str2.length();
|
|
if (length != 64) {
|
|
Single$$ExternalSyntheticBUOutline0.m$3(a$$ExternalSyntheticOutline0.m(length, "Base64Alphabet length must be exactly 64 (was ", MarkdownConstants.RIGHT_PARENTHESIS));
|
|
throw null;
|
|
}
|
|
str2.getChars(0, length, cArr, 0);
|
|
Arrays.fill(iArr, -1);
|
|
for (int i2 = 0; i2 < length; i2++) {
|
|
char c2 = this._base64ToAsciiC[i2];
|
|
this._base64ToAsciiB[i2] = (byte) c2;
|
|
this._asciiToBase64[c2] = i2;
|
|
}
|
|
if (z) {
|
|
this._asciiToBase64[c] = -2;
|
|
}
|
|
}
|
|
|
|
public int decodeBase64Byte(byte b) {
|
|
if (b <= Byte.MAX_VALUE) {
|
|
return this._asciiToBase64[b];
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
public int decodeBase64Char(char c) {
|
|
if (c <= 127) {
|
|
return this._asciiToBase64[c];
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
public String encode(byte[] bArr, boolean z) {
|
|
int length = bArr.length;
|
|
StringBuilder sb = new StringBuilder((length >> 2) + length + (length >> 3));
|
|
if (z) {
|
|
sb.append('\"');
|
|
}
|
|
int maxLineLength = getMaxLineLength() >> 2;
|
|
int i = length - 3;
|
|
int i2 = 0;
|
|
while (i2 <= i) {
|
|
int i3 = i2 + 2;
|
|
int i4 = ((bArr[i2 + 1] & 255) | (bArr[i2] << 8)) << 8;
|
|
i2 += 3;
|
|
encodeBase64Chunk(sb, i4 | (bArr[i3] & 255));
|
|
maxLineLength--;
|
|
if (maxLineLength <= 0) {
|
|
sb.append('\\');
|
|
sb.append('n');
|
|
maxLineLength = getMaxLineLength() >> 2;
|
|
}
|
|
}
|
|
int i5 = length - i2;
|
|
if (i5 > 0) {
|
|
int i6 = i2 + 1;
|
|
int i7 = bArr[i2] << 16;
|
|
if (i5 == 2) {
|
|
i7 |= (bArr[i6] & 255) << 8;
|
|
}
|
|
encodeBase64Partial(sb, i7, i5);
|
|
}
|
|
if (z) {
|
|
sb.append('\"');
|
|
}
|
|
return sb.toString();
|
|
}
|
|
|
|
public byte encodeBase64BitsAsByte(int i) {
|
|
return this._base64ToAsciiB[i];
|
|
}
|
|
|
|
public char encodeBase64BitsAsChar(int i) {
|
|
return this._base64ToAsciiC[i];
|
|
}
|
|
|
|
public void encodeBase64Chunk(StringBuilder sb, int i) {
|
|
sb.append(this._base64ToAsciiC[(i >> 18) & 63]);
|
|
sb.append(this._base64ToAsciiC[(i >> 12) & 63]);
|
|
sb.append(this._base64ToAsciiC[(i >> 6) & 63]);
|
|
sb.append(this._base64ToAsciiC[i & 63]);
|
|
}
|
|
|
|
public int encodeBase64Partial(int i, int i2, char[] cArr, int i3) {
|
|
char[] cArr2 = this._base64ToAsciiC;
|
|
cArr[i3] = cArr2[(i >> 18) & 63];
|
|
int i4 = i3 + 2;
|
|
cArr[i3 + 1] = cArr2[(i >> 12) & 63];
|
|
if (this._usesPadding) {
|
|
int i5 = i3 + 3;
|
|
cArr[i4] = i2 == 2 ? cArr2[(i >> 6) & 63] : this._paddingChar;
|
|
int i6 = i3 + 4;
|
|
cArr[i5] = this._paddingChar;
|
|
return i6;
|
|
}
|
|
if (i2 != 2) {
|
|
return i4;
|
|
}
|
|
int i7 = i3 + 3;
|
|
cArr[i4] = cArr2[(i >> 6) & 63];
|
|
return i7;
|
|
}
|
|
|
|
public int getMaxLineLength() {
|
|
return this._maxLineLength;
|
|
}
|
|
|
|
public String getName() {
|
|
return this._name;
|
|
}
|
|
|
|
public byte getPaddingByte() {
|
|
return (byte) this._paddingChar;
|
|
}
|
|
|
|
public char getPaddingChar() {
|
|
return this._paddingChar;
|
|
}
|
|
|
|
public String toString() {
|
|
return this._name;
|
|
}
|
|
|
|
public boolean usesPadding() {
|
|
return this._usesPadding;
|
|
}
|
|
|
|
public boolean usesPaddingChar(char c) {
|
|
return c == this._paddingChar;
|
|
}
|
|
|
|
public boolean usesPaddingChar(int i) {
|
|
return i == this._paddingChar;
|
|
}
|
|
|
|
public int decodeBase64Char(int i) {
|
|
if (i <= 127) {
|
|
return this._asciiToBase64[i];
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
public int encodeBase64Chunk(int i, char[] cArr, int i2) {
|
|
char[] cArr2 = this._base64ToAsciiC;
|
|
cArr[i2] = cArr2[(i >> 18) & 63];
|
|
cArr[i2 + 1] = cArr2[(i >> 12) & 63];
|
|
int i3 = i2 + 3;
|
|
cArr[i2 + 2] = cArr2[(i >> 6) & 63];
|
|
int i4 = i2 + 4;
|
|
cArr[i3] = cArr2[i & 63];
|
|
return i4;
|
|
}
|
|
|
|
public int encodeBase64Chunk(int i, byte[] bArr, int i2) {
|
|
byte[] bArr2 = this._base64ToAsciiB;
|
|
bArr[i2] = bArr2[(i >> 18) & 63];
|
|
bArr[i2 + 1] = bArr2[(i >> 12) & 63];
|
|
int i3 = i2 + 3;
|
|
bArr[i2 + 2] = bArr2[(i >> 6) & 63];
|
|
int i4 = i2 + 4;
|
|
bArr[i3] = bArr2[i & 63];
|
|
return i4;
|
|
}
|
|
|
|
public void encodeBase64Partial(StringBuilder sb, int i, int i2) {
|
|
sb.append(this._base64ToAsciiC[(i >> 18) & 63]);
|
|
sb.append(this._base64ToAsciiC[(i >> 12) & 63]);
|
|
if (this._usesPadding) {
|
|
sb.append(i2 == 2 ? this._base64ToAsciiC[(i >> 6) & 63] : this._paddingChar);
|
|
sb.append(this._paddingChar);
|
|
} else if (i2 == 2) {
|
|
sb.append(this._base64ToAsciiC[(i >> 6) & 63]);
|
|
}
|
|
}
|
|
|
|
public int encodeBase64Partial(int i, int i2, byte[] bArr, int i3) {
|
|
byte[] bArr2 = this._base64ToAsciiB;
|
|
bArr[i3] = bArr2[(i >> 18) & 63];
|
|
int i4 = i3 + 2;
|
|
bArr[i3 + 1] = bArr2[(i >> 12) & 63];
|
|
if (!this._usesPadding) {
|
|
if (i2 != 2) {
|
|
return i4;
|
|
}
|
|
int i5 = i3 + 3;
|
|
bArr[i4] = bArr2[(i >> 6) & 63];
|
|
return i5;
|
|
}
|
|
byte b = (byte) this._paddingChar;
|
|
int i6 = i3 + 3;
|
|
bArr[i4] = i2 == 2 ? bArr2[(i >> 6) & 63] : b;
|
|
int i7 = i3 + 4;
|
|
bArr[i6] = b;
|
|
return i7;
|
|
}
|
|
|
|
public Base64Variant(Base64Variant base64Variant, String str, int i) {
|
|
this(base64Variant, str, base64Variant._usesPadding, base64Variant._paddingChar, i);
|
|
}
|
|
|
|
public Base64Variant(Base64Variant base64Variant, String str, boolean z, char c, int i) {
|
|
int[] iArr = new int[128];
|
|
this._asciiToBase64 = iArr;
|
|
char[] cArr = new char[64];
|
|
this._base64ToAsciiC = cArr;
|
|
byte[] bArr = new byte[64];
|
|
this._base64ToAsciiB = bArr;
|
|
this._name = str;
|
|
byte[] bArr2 = base64Variant._base64ToAsciiB;
|
|
System.arraycopy(bArr2, 0, bArr, 0, bArr2.length);
|
|
char[] cArr2 = base64Variant._base64ToAsciiC;
|
|
System.arraycopy(cArr2, 0, cArr, 0, cArr2.length);
|
|
int[] iArr2 = base64Variant._asciiToBase64;
|
|
System.arraycopy(iArr2, 0, iArr, 0, iArr2.length);
|
|
this._usesPadding = z;
|
|
this._paddingChar = c;
|
|
this._maxLineLength = i;
|
|
}
|
|
|
|
public String encode(byte[] bArr) {
|
|
return encode(bArr, false);
|
|
}
|
|
}
|