package x9; import java.io.Serializable; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Arrays; /* loaded from: classes2.dex */ public class f implements Serializable, Comparable { /* renamed from: d, reason: collision with root package name */ static final char[] f15469d = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; /* renamed from: e, reason: collision with root package name */ public static final f f15470e = j(new byte[0]); /* renamed from: a, reason: collision with root package name */ final byte[] f15471a; /* renamed from: b, reason: collision with root package name */ transient int f15472b; /* renamed from: c, reason: collision with root package name */ transient String f15473c; f(byte[] bArr) { this.f15471a = bArr; } static int b(String str, int i10) { int length = str.length(); int i11 = 0; int i12 = 0; while (i11 < length) { if (i12 == i10) { return i11; } int codePointAt = str.codePointAt(i11); if ((Character.isISOControl(codePointAt) && codePointAt != 10 && codePointAt != 13) || codePointAt == 65533) { return -1; } i12++; i11 += Character.charCount(codePointAt); } return str.length(); } public static f d(String str) { if (str == null) { throw new IllegalArgumentException("hex == null"); } if (str.length() % 2 != 0) { throw new IllegalArgumentException("Unexpected hex string: " + str); } int length = str.length() / 2; byte[] bArr = new byte[length]; for (int i10 = 0; i10 < length; i10++) { int i11 = i10 * 2; bArr[i10] = (byte) ((e(str.charAt(i11)) << 4) + e(str.charAt(i11 + 1))); } return j(bArr); } private static int e(char c10) { if (c10 >= '0' && c10 <= '9') { return c10 - '0'; } char c11 = 'a'; if (c10 < 'a' || c10 > 'f') { c11 = 'A'; if (c10 < 'A' || c10 > 'F') { throw new IllegalArgumentException("Unexpected hex digit: " + c10); } } return (c10 - c11) + 10; } private f f(String str) { try { return j(MessageDigest.getInstance(str).digest(this.f15471a)); } catch (NoSuchAlgorithmException e10) { throw new AssertionError(e10); } } public static f g(String str) { if (str == null) { throw new IllegalArgumentException("s == null"); } f fVar = new f(str.getBytes(x.f15523a)); fVar.f15473c = str; return fVar; } public static f j(byte... bArr) { if (bArr != null) { return new f((byte[]) bArr.clone()); } throw new IllegalArgumentException("data == null"); } public String a() { return b.a(this.f15471a); } @Override // java.lang.Comparable /* renamed from: c, reason: merged with bridge method [inline-methods] */ public int compareTo(f fVar) { int n10 = n(); int n11 = fVar.n(); int min = Math.min(n10, n11); for (int i10 = 0; i10 < min; i10++) { int h10 = h(i10) & 255; int h11 = fVar.h(i10) & 255; if (h10 != h11) { return h10 < h11 ? -1 : 1; } } if (n10 == n11) { return 0; } return n10 < n11 ? -1 : 1; } public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof f) { f fVar = (f) obj; int n10 = fVar.n(); byte[] bArr = this.f15471a; if (n10 == bArr.length && fVar.l(0, bArr, 0, bArr.length)) { return true; } } return false; } public byte h(int i10) { return this.f15471a[i10]; } public int hashCode() { int i10 = this.f15472b; if (i10 != 0) { return i10; } int hashCode = Arrays.hashCode(this.f15471a); this.f15472b = hashCode; return hashCode; } public String i() { byte[] bArr = this.f15471a; char[] cArr = new char[bArr.length * 2]; int i10 = 0; for (byte b10 : bArr) { int i11 = i10 + 1; char[] cArr2 = f15469d; cArr[i10] = cArr2[(b10 >> 4) & 15]; i10 = i11 + 1; cArr[i11] = cArr2[b10 & 15]; } return new String(cArr); } public boolean k(int i10, f fVar, int i11, int i12) { return fVar.l(i11, this.f15471a, i10, i12); } public boolean l(int i10, byte[] bArr, int i11, int i12) { if (i10 >= 0) { byte[] bArr2 = this.f15471a; if (i10 <= bArr2.length - i12 && i11 >= 0 && i11 <= bArr.length - i12 && x.a(bArr2, i10, bArr, i11, i12)) { return true; } } return false; } public f m() { return f("SHA-256"); } public int n() { return this.f15471a.length; } public final boolean o(f fVar) { return k(0, fVar, 0, fVar.n()); } public f p(int i10, int i11) { if (i10 < 0) { throw new IllegalArgumentException("beginIndex < 0"); } byte[] bArr = this.f15471a; if (i11 > bArr.length) { throw new IllegalArgumentException("endIndex > length(" + this.f15471a.length + ")"); } int i12 = i11 - i10; if (i12 < 0) { throw new IllegalArgumentException("endIndex < beginIndex"); } if (i10 == 0 && i11 == bArr.length) { return this; } byte[] bArr2 = new byte[i12]; System.arraycopy(bArr, i10, bArr2, 0, i12); return new f(bArr2); } public f q() { int i10 = 0; while (true) { byte[] bArr = this.f15471a; if (i10 >= bArr.length) { return this; } byte b10 = bArr[i10]; if (b10 >= 65 && b10 <= 90) { byte[] bArr2 = (byte[]) bArr.clone(); bArr2[i10] = (byte) (b10 + 32); for (int i11 = i10 + 1; i11 < bArr2.length; i11++) { byte b11 = bArr2[i11]; if (b11 >= 65 && b11 <= 90) { bArr2[i11] = (byte) (b11 + 32); } } return new f(bArr2); } i10++; } } public byte[] r() { return (byte[]) this.f15471a.clone(); } public String s() { String str = this.f15473c; if (str != null) { return str; } String str2 = new String(this.f15471a, x.f15523a); this.f15473c = str2; return str2; } void t(c cVar) { byte[] bArr = this.f15471a; cVar.l(bArr, 0, bArr.length); } public String toString() { if (this.f15471a.length == 0) { return "[size=0]"; } String s10 = s(); int b10 = b(s10, 64); if (b10 == -1) { if (this.f15471a.length <= 64) { return "[hex=" + i() + "]"; } return "[size=" + this.f15471a.length + " hex=" + p(0, 64).i() + "…]"; } String replace = s10.substring(0, b10).replace("\\", "\\\\").replace("\n", "\\n").replace("\r", "\\r"); if (b10 >= s10.length()) { return "[text=" + replace + "]"; } return "[size=" + this.f15471a.length + " text=" + replace + "…]"; } }