[Java] 纯文本查看 复制代码//
// Decompiled by Jadx - 766ms
//
import android.text.TextUtils;
import android.util.Base64;
import java.security.Key;
import java.util.Random;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
public class AesCrypto {
public static final String a = "df0b".toLowerCase();
public static final byte[] b = Base64.decode("VlEc5qsEDXWChrWJ0AzMXQ==", 2);
public static final byte[] c = Base64.decode("MC8Lpxk9zqyuRPXMdO8rJQ==", 2);
public static final byte[] d = a();
public static String a(String str, byte[] bArr) throws Exception {
return a(a(b(b), str.getBytes(), bArr));
}
public static String a(String str) throws Exception {
byte[] a = a();
String a2 = a(str, a);
String a3 = a(a);
int parseInt = Integer.parseInt(a.substring(0, 1), 16);
return a + a2.substring(0, parseInt) + a3 + a2.substring(parseInt);
}
public static String b(String str) throws Exception {
return b(str, a, b);
}
public static String c(String str) throws Exception {
return a(str, a, b);
}
public static String d(String str) throws Exception {
return a(str, "4545", c);
}
private static String a(String str, String str2, byte[] bArr) throws Exception {
if (TextUtils.isEmpty(str)) {
return "";
}
byte[] decode = Base64.decode(str, 2);
String toLowerCase = ByteTransformUtils.a(decode, 0, decode.length).toLowerCase();
if (toLowerCase.startsWith(str2)) {
toLowerCase = toLowerCase.substring(str2.length());
}
int parseInt = Integer.parseInt(str2.substring(0, 1), 16);
String substring = toLowerCase.substring(parseInt, parseInt + 32);
return new String(b(b(bArr), e(toLowerCase.substring(0, parseInt) + toLowerCase.substring(parseInt + 32)), ByteTransformUtils.a(substring)));
}
private static String b(String str, String str2, byte[] bArr) throws Exception {
byte[] a = a();
String a2 = a(a(b(bArr), str.getBytes(), a));
String a3 = a(a);
int parseInt = Integer.parseInt(str2.substring(0, 1), 16);
return Base64.encodeToString(ByteTransformUtils.a(str2 + a2.substring(0, parseInt) + a3 + a2.substring(parseInt)), 2);
}
private static byte[] b(byte[] bArr) throws Exception {
return bArr;
}
private static byte[] a(byte[] bArr, byte[] bArr2, byte[] bArr3) throws Exception {
Key secretKeySpec = new SecretKeySpec(bArr, "AES");
Cipher instance = Cipher.getInstance("AES/CBC/PKCS7Padding");
instance.init(1, secretKeySpec, new IvParameterSpec(bArr3));
return instance.doFinal(bArr2);
}
private static byte[] b(byte[] bArr, byte[] bArr2, byte[] bArr3) throws Exception {
Key secretKeySpec = new SecretKeySpec(bArr, "AES");
Cipher instance = Cipher.getInstance("AES/CBC/PKCS7Padding");
instance.init(2, secretKeySpec, new IvParameterSpec(bArr3));
return instance.doFinal(bArr2);
}
public static byte[] e(String str) {
int length = str.length() / 2;
byte[] bArr = new byte[length];
for (int i = 0; i < length; i++) {
bArr[i] = Integer.valueOf(str.substring(i * 2, (i * 2) + 2), 16).byteValue();
}
return bArr;
}
public static String a(byte[] bArr) {
if (bArr == null) {
return "";
}
StringBuffer stringBuffer = new StringBuffer(bArr.length * 2);
for (byte a : bArr) {
a(stringBuffer, a);
}
return stringBuffer.toString();
}
private static void a(StringBuffer stringBuffer, byte b) {
stringBuffer.append("0123456789ABCDEF".charAt((b >> 4) & 15)).append("0123456789ABCDEF".charAt(b & 15));
}
private static byte[] a() {
Random random = new Random();
byte[] bArr = new byte[16];
for (int i = 0; i < 16; i++) {
bArr[i] = (byte) (random.nextInt(256) - 128);
}
return bArr;
}
}