package o; import com.google.common.primitives.UnsignedBytes; import com.kofax.mobile.sdk._internal.impl.extraction.kta.KtaJsonExactionHelper; import java.io.EOFException; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.lang.reflect.Field; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Arrays; /* loaded from: classes6.dex */ public class giP implements Serializable, Comparable { private transient int b; public transient String c; public final byte[] d; private static char[] e = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; public static final giP a = new giP((byte[]) new byte[0].clone()); @Override // java.lang.Comparable public /* synthetic */ int compareTo(giP gip) { giP gip2 = gip; int length = this.d.length; int length2 = gip2.d.length; int min = Math.min(length, length2); for (int i = 0; i < min; i++) { int i2 = this.d[i] & UnsignedBytes.MAX_VALUE; int i3 = gip2.d[i] & UnsignedBytes.MAX_VALUE; if (i2 != i3) { return i2 >= i3 ? 1 : -1; } } if (length == length2) { return 0; } return length >= length2 ? 1 : -1; } /* JADX INFO: Access modifiers changed from: package-private */ public giP(byte[] bArr) { this.d = bArr; } public static giP c(byte... bArr) { if (bArr == null) { throw new IllegalArgumentException("data == null"); } return new giP((byte[]) bArr.clone()); } public static giP b(String str) { if (str == null) { throw new IllegalArgumentException("s == null"); } giP gip = new giP(str.getBytes(C15183gjd.e)); gip.c = str; return gip; } private giP e(String str) { try { byte[] digest = MessageDigest.getInstance(str).digest(this.d); if (digest == null) { throw new IllegalArgumentException("data == null"); } return new giP((byte[]) digest.clone()); } catch (NoSuchAlgorithmException e2) { throw new AssertionError(e2); } } public static giP d(String str) { if (str == null) { throw new IllegalArgumentException("base64 == null"); } byte[] c = C15180gja.c(str); if (c != null) { return new giP(c); } return null; } public final String b() { byte[] bArr = this.d; char[] cArr = new char[bArr.length << 1]; int length = bArr.length; int i = 0; int i2 = 0; while (i2 < length) { byte b = bArr[i2]; char[] cArr2 = e; cArr[i] = cArr2[(b >> 4) & 15]; cArr[i + 1] = cArr2[b & 15]; i2++; i += 2; } return new String(cArr); } public final giP c() { int i = 0; while (true) { byte[] bArr = this.d; if (i >= bArr.length) { return this; } byte b = bArr[i]; if (b >= 65 && b <= 90) { byte[] bArr2 = (byte[]) bArr.clone(); bArr2[i] = (byte) (b + 32); for (int i2 = i + 1; i2 < bArr2.length; i2++) { byte b2 = bArr2[i2]; if (b2 >= 65 && b2 <= 90) { bArr2[i2] = (byte) (b2 + 32); } } return new giP(bArr2); } i++; } } public final byte[] e() { return (byte[]) this.d.clone(); } public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof giP) { byte[] bArr = ((giP) obj).d; int length = bArr.length; byte[] bArr2 = this.d; if (length == bArr2.length) { int length2 = bArr2.length; if (bArr.length - length2 >= 0 && bArr2.length - length2 >= 0 && C15183gjd.b(bArr, bArr2, length2)) { return true; } } } return false; } public int hashCode() { int i = this.b; if (i != 0) { return i; } int hashCode = Arrays.hashCode(this.d); this.b = hashCode; return hashCode; } public String toString() { byte[] bArr = this.d; if (bArr.length == 0) { return "ByteString[size=0]"; } if (bArr.length <= 16) { int length = bArr.length; return String.format("ByteString[size=%s data=%s]", Integer.valueOf(length), b()); } int length2 = bArr.length; return String.format("ByteString[size=%s md5=%s]", Integer.valueOf(length2), e("MD5").b()); } private void readObject(ObjectInputStream objectInputStream) throws IOException { int readInt = objectInputStream.readInt(); if (objectInputStream == null) { throw new IllegalArgumentException("in == null"); } if (readInt < 0) { throw new IllegalArgumentException("byteCount < 0: ".concat(String.valueOf(readInt))); } byte[] bArr = new byte[readInt]; int i = 0; while (i < readInt) { int read = objectInputStream.read(bArr, i, readInt - i); if (read == -1) { throw new EOFException(); } i += read; } giP gip = new giP(bArr); try { Field declaredField = giP.class.getDeclaredField(KtaJsonExactionHelper.OBJECT); declaredField.setAccessible(true); declaredField.set(this, gip.d); } catch (IllegalAccessException unused) { throw new AssertionError(); } catch (NoSuchFieldException unused2) { throw new AssertionError(); } } private void writeObject(ObjectOutputStream objectOutputStream) throws IOException { objectOutputStream.writeInt(this.d.length); objectOutputStream.write(this.d); } }