151 lines
5.4 KiB
Java
151 lines
5.4 KiB
Java
package com.ijm.dataencryption.de;
|
|
|
|
import android.content.Context;
|
|
import android.text.TextUtils;
|
|
import android.util.Log;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.security.MessageDigest;
|
|
import java.security.NoSuchAlgorithmException;
|
|
import java.util.Properties;
|
|
import java.util.Random;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class DataDecryptTool {
|
|
private static final String DATA_DECRYPT_CONFIG_FILENAME = "data_decrypt_config.properties";
|
|
public static final int DECRYPT_ALL_FILE = 256;
|
|
public static final int DECRYPT_DB_FILE = 512;
|
|
public static final int DECRYPT_SP_FILE = 1024;
|
|
public static final int ENCRYPT_DB = 2;
|
|
public static final int ENCRYPT_SP = 1;
|
|
private static final String KEY_DDECRYPT_SDK_VNAME = "ddecrypt_sdk_vname";
|
|
private static boolean isAccredited = false;
|
|
|
|
private static void byte2hex(byte b, StringBuffer stringBuffer) {
|
|
char[] cArr = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
|
stringBuffer.append(cArr[(b & 240) >> 4]);
|
|
stringBuffer.append(cArr[b & 15]);
|
|
}
|
|
|
|
private static native boolean dowork(String str, int i, String str2, String str3, String str4);
|
|
|
|
public static void doworkForDecrypt(Context context, int i) {
|
|
if (!isAccredited) {
|
|
Log.i("ijm", "application is not effect accredit.");
|
|
return;
|
|
}
|
|
long currentTimeMillis = System.currentTimeMillis();
|
|
dowork("qmFJh65QoklKoT9Vs7hFrSU=;" + context.getPackageName(), i, (md5(String.valueOf(currentTimeMillis)) + md5(String.valueOf(new Random().nextLong() + currentTimeMillis))).toUpperCase(), "", "0x16384");
|
|
}
|
|
|
|
private static String getFinger(String str, byte[] bArr) {
|
|
try {
|
|
return toHexString(MessageDigest.getInstance(str).digest(bArr));
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
return "";
|
|
}
|
|
}
|
|
|
|
public static String getVersion(Context context) {
|
|
String str;
|
|
Context applicationContext = context.getApplicationContext();
|
|
InputStream inputStream = null;
|
|
try {
|
|
try {
|
|
Properties properties = new Properties();
|
|
inputStream = applicationContext.getAssets().open(DATA_DECRYPT_CONFIG_FILENAME);
|
|
properties.load(inputStream);
|
|
str = properties.getProperty(KEY_DDECRYPT_SDK_VNAME);
|
|
if (inputStream != null) {
|
|
try {
|
|
inputStream.close();
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
} catch (Throwable th) {
|
|
if (inputStream != null) {
|
|
try {
|
|
inputStream.close();
|
|
} catch (IOException e2) {
|
|
e2.printStackTrace();
|
|
}
|
|
}
|
|
throw th;
|
|
}
|
|
} catch (Exception e3) {
|
|
e3.printStackTrace();
|
|
if (inputStream != null) {
|
|
try {
|
|
inputStream.close();
|
|
} catch (IOException e4) {
|
|
e4.printStackTrace();
|
|
}
|
|
}
|
|
str = "Unknown";
|
|
}
|
|
return "Unknown".equals(str) ? "2.0.0" : str;
|
|
}
|
|
|
|
private static String md5(String str) {
|
|
if (TextUtils.isEmpty(str)) {
|
|
return "";
|
|
}
|
|
try {
|
|
byte[] digest = MessageDigest.getInstance("MD5").digest(str.getBytes());
|
|
StringBuilder sb = new StringBuilder();
|
|
for (byte b : digest) {
|
|
String hexString = Integer.toHexString(b & 255);
|
|
if (hexString.length() == 1) {
|
|
hexString = "0" + hexString;
|
|
}
|
|
sb.append(hexString);
|
|
}
|
|
return sb.toString();
|
|
} catch (NoSuchAlgorithmException e) {
|
|
e.printStackTrace();
|
|
return "";
|
|
}
|
|
}
|
|
|
|
private static native String setKey(Context context, String str);
|
|
|
|
public static StatusInfo setLicenseKey(Context context, String str) {
|
|
try {
|
|
if (context == null) {
|
|
return new StatusInfo(-6);
|
|
}
|
|
try {
|
|
System.loadLibrary("ijmDataDecryption");
|
|
String[] split = setKey(context, str).split(";");
|
|
StatusInfo statusInfo = new StatusInfo();
|
|
if (split.length > 1) {
|
|
statusInfo.setStatusCode(Integer.valueOf(split[0]).intValue());
|
|
statusInfo.setExpiredDate(split[1]);
|
|
} else if (split.length > 0) {
|
|
statusInfo.setStatusCode(Integer.valueOf(split[0]).intValue());
|
|
statusInfo.setExpiredDate("");
|
|
}
|
|
if (statusInfo.getStatusCode() == 1) {
|
|
isAccredited = true;
|
|
}
|
|
return statusInfo;
|
|
} catch (Throwable th) {
|
|
th.printStackTrace();
|
|
return new StatusInfo(-7);
|
|
}
|
|
} catch (Exception unused) {
|
|
return new StatusInfo();
|
|
}
|
|
}
|
|
|
|
private static String toHexString(byte[] bArr) {
|
|
StringBuffer stringBuffer = new StringBuffer();
|
|
for (byte b : bArr) {
|
|
byte2hex(b, stringBuffer);
|
|
}
|
|
return stringBuffer.toString();
|
|
}
|
|
}
|