93 lines
3.8 KiB
Java
93 lines
3.8 KiB
Java
package com.discord.utilities.sms;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.content.Context;
|
|
import android.content.ContextWrapper;
|
|
import android.util.Base64;
|
|
import c.q.a.k.a;
|
|
import com.discord.app.AppLog;
|
|
import com.discord.utilities.logging.Logger;
|
|
import d0.g;
|
|
import d0.z.d.m;
|
|
import java.security.MessageDigest;
|
|
import java.security.NoSuchAlgorithmException;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import kotlin.Lazy;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
/* compiled from: AppSignatureHelper.kt */
|
|
@SuppressLint({"PackageManagerGetSignatures"})
|
|
public final class AppSignatureHelper extends ContextWrapper {
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final String HASH_TYPE = "SHA-256";
|
|
private static final int NUM_BASE64_CHAR = 11;
|
|
private static final int NUM_HASHED_BYTES = 9;
|
|
private static final String TAG;
|
|
private final Lazy appSignatures$delegate = g.lazy(new AppSignatureHelper$appSignatures$2(this));
|
|
|
|
/* compiled from: AppSignatureHelper.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public static final /* synthetic */ String access$hash(Companion companion, String str, String str2) {
|
|
return companion.hash(str, str2);
|
|
}
|
|
|
|
private final String hash(String str, String str2) {
|
|
String str3 = str + ' ' + str2;
|
|
try {
|
|
MessageDigest instance = MessageDigest.getInstance("SHA-256");
|
|
m.checkNotNullExpressionValue(instance, "MessageDigest.getInstance(HASH_TYPE)");
|
|
instance.update(a.m(str3));
|
|
byte[] digest = instance.digest();
|
|
m.checkNotNullExpressionValue(digest, "messageDigest.digest()");
|
|
byte[] copyOfRange = Arrays.copyOfRange(digest, 0, 9);
|
|
m.checkNotNullExpressionValue(copyOfRange, "Arrays.copyOfRange(hashS…ure, 0, NUM_HASHED_BYTES)");
|
|
String encodeToString = Base64.encodeToString(copyOfRange, 3);
|
|
m.checkNotNullExpressionValue(encodeToString, "Base64.encodeToString(ha…ADDING or Base64.NO_WRAP)");
|
|
if (encodeToString != null) {
|
|
String substring = encodeToString.substring(0, 11);
|
|
m.checkNotNullExpressionValue(substring, "(this as java.lang.Strin…ing(startIndex, endIndex)");
|
|
AppLog appLog = AppLog.g;
|
|
String tag = getTAG();
|
|
String format = String.format("pkg: %s -- hash: %s", Arrays.copyOf(new Object[]{str, substring}, 2));
|
|
m.checkNotNullExpressionValue(format, "java.lang.String.format(format, *args)");
|
|
Logger.d$default(appLog, tag, format, null, 4, null);
|
|
return substring;
|
|
}
|
|
throw new NullPointerException("null cannot be cast to non-null type java.lang.String");
|
|
} catch (NoSuchAlgorithmException e) {
|
|
Logger.e$default(AppLog.g, getTAG(), "hash:NoSuchAlgorithm", e, null, 8, null);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public final String getTAG() {
|
|
return AppSignatureHelper.access$getTAG$cp();
|
|
}
|
|
}
|
|
|
|
static {
|
|
String simpleName = AppSignatureHelper.class.getSimpleName();
|
|
m.checkNotNullExpressionValue(simpleName, "AppSignatureHelper::class.java.simpleName");
|
|
TAG = simpleName;
|
|
}
|
|
|
|
public AppSignatureHelper(Context context) {
|
|
super(context);
|
|
}
|
|
|
|
public static final /* synthetic */ String access$getTAG$cp() {
|
|
return TAG;
|
|
}
|
|
|
|
public final ArrayList<String> getAppSignatures() {
|
|
return (ArrayList) this.appSignatures$delegate.getValue();
|
|
}
|
|
}
|