aes 源码 java_请JAVA高手帮忙在源码里找出AesCrypto方法

[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;

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值