what-the-bank/sources/o/Tll.java

64 lines
2.3 KiB
Java

package o;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import java.io.CharConversionException;
import java.io.FileNotFoundException;
import java.io.IOException;
/* loaded from: classes2.dex */
public final class Tll implements gEg {
private final SharedPreferences a;
private final String b;
public Tll(Context context, String str, String str2) throws IOException {
if (str == null) {
throw new IllegalArgumentException("keysetName cannot be null");
}
this.b = str;
Context applicationContext = context.getApplicationContext();
if (str2 == null) {
this.a = PreferenceManager.getDefaultSharedPreferences(applicationContext);
} else {
this.a = applicationContext.getSharedPreferences(str2, 0);
}
}
private byte[] d() throws IOException {
try {
String string = this.a.getString(this.b, null);
if (string == null) {
throw new FileNotFoundException(String.format("can't read keyset; the pref value %s does not exist", this.b));
}
if (string.length() % 2 != 0) {
throw new IllegalArgumentException("Expected a string of even length");
}
int length = string.length() / 2;
byte[] bArr = new byte[length];
for (int i = 0; i < length; i++) {
int i2 = i << 1;
int digit = Character.digit(string.charAt(i2), 16);
int digit2 = Character.digit(string.charAt(i2 + 1), 16);
if (digit == -1 || digit2 == -1) {
throw new IllegalArgumentException("input is not hexadecimal");
}
bArr[i] = (byte) ((digit << 4) + digit2);
}
return bArr;
} catch (ClassCastException | IllegalArgumentException unused) {
throw new CharConversionException(String.format("can't read keyset; the pref value %s is not a valid hex string", this.b));
}
}
@Override // o.gEg
public final Yzk c() throws IOException {
return Yzk.c(d(), C1458aEp.c());
}
@Override // o.gEg
public final C0587KSr e() throws IOException {
return C0587KSr.b(d(), C1458aEp.c());
}
}