package com.PEP.biaori.util;
import
android.content.Context;
import
android.content.pm.PackageInfo;
import
android.content.pm.PackageManager;
import
android.util.Log;
import
java.io.ByteArrayInputStream;
import
java.security.MessageDigest;
import
java.security.NoSuchAlgorithmException;
import
java.security.cert.CertificateEncodingException;
import
java.security.cert.CertificateFactory;
import
java.security.cert.X509Certificate;
/
*
compiled
from
: SignCheck.java
*
/
/
*
loaded
from
: classes2.dex
*
/
public
class
af {
private static final String d
=
"SignCheck"
;
/
*
renamed
from
: a reason: collision with root package name
*
/
private Context f7298a;
/
*
renamed
from
: b reason: collision with root package name
*
/
private String f7299b;
private String c;
public af(Context context) {
this.f7299b
=
null;
this.c
=
"1C:8D:A9:52:F8:C4:74:7C:7C:DD:B4:78:40:F0:C1:61:E0:AC:E9:F7"
;
this.f7298a
=
context;
this.f7299b
=
b();
}
public af(Context context, String
str
) {
this.f7299b
=
null;
this.c
=
"1C:8D:A9:52:F8:C4:74:7C:7C:DD:B4:78:40:F0:C1:61:E0:AC:E9:F7"
;
this.f7298a
=
context;
this.c
=
str
;
this.f7299b
=
b();
}
public String a() {
return
this.c;
}
public void a(String
str
) {
this.c
=
str
;
}
public String b() {
PackageInfo packageInfo;
CertificateFactory certificateFactory;
X509Certificate x509Certificate;
byte[] digest;
String
str
=
null;
try
{
packageInfo
=
this.f7298a.getPackageManager().getPackageInfo(this.f7298a.getPackageName(),
64
);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
packageInfo
=
null;
}
ByteArrayInputStream byteArrayInputStream
=
new ByteArrayInputStream(packageInfo.signatures[
0
].toByteArray());
try
{
certificateFactory
=
CertificateFactory.getInstance(
"X509"
);
} catch (Exception e2) {
e2.printStackTrace();
certificateFactory
=
null;
}
try
{
x509Certificate
=
(X509Certificate) certificateFactory.generateCertificate(byteArrayInputStream);
} catch (Exception e3) {
e3.printStackTrace();
x509Certificate
=
null;
}
try
{
byte[] bArr
=
new byte[
0
];
try
{
digest
=
MessageDigest.getInstance(
"SHA1"
).digest(x509Certificate.getEncoded());
} catch (CertificateEncodingException e4) {
e4.printStackTrace();
}
str
=
a(digest);
} catch (NoSuchAlgorithmException e5) {
e5.printStackTrace();
}
Log.d(
"签名校验"
,
"SHA1 = "
+
str
);
return
str
;
}
private String a(byte[] bArr) {
StringBuilder sb
=
new StringBuilder(bArr.length
*
2
);
for
(
int
i
=
0
; i < bArr.length; i
+
+
) {
String hexString
=
Integer.toHexString(bArr[i]);
int
length
=
hexString.length();
if
(length
=
=
1
) {
hexString
=
"0"
+
hexString;
}
if
(length >
2
) {
hexString
=
hexString.substring(length
-
2
, length);
}
sb.append(hexString.toUpperCase());
if
(i < bArr.length
-
1
) {
sb.append(
':'
);
}
}
return
sb.toString();
}
public boolean c() {
if
(this.c !
=
null) {
this.f7299b
=
this.f7299b.trim();
String trim
=
this.c.trim();
this.c
=
trim;
return
this.f7299b.equals(trim);
}
return
false;
}
}