jimu-decompiled/sources/com/baidu/license/util/mas.java
2025-05-13 19:24:51 +02:00

50 lines
1.7 KiB
Java

package com.baidu.license.util;
import com.ubtrobot.jimu.robotapi.PeripheralType;
import java.io.ByteArrayOutputStream;
import java.security.KeyFactory;
import java.security.spec.PKCS8EncodedKeySpec;
import javax.crypto.Cipher;
/* compiled from: RsaUtil.java */
/* loaded from: classes.dex */
public final class mas {
public static String a(String str, String str2) {
byte[] a = nx.a(str);
byte[] a2 = nx.a(str2);
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
cipher.init(2, keyFactory.generatePrivate(new PKCS8EncodedKeySpec(a2)));
return new String(a(a, cipher));
}
private static byte[] a(byte[] bArr, Cipher cipher) {
byte[] doFinal;
try {
int length = bArr.length;
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
int i = 0;
int i2 = 0;
while (true) {
int i3 = length - i;
if (i3 > 0) {
if (i3 > 128) {
doFinal = cipher.doFinal(bArr, i, PeripheralType.SERVO);
} else {
doFinal = cipher.doFinal(bArr, i, i3);
}
byteArrayOutputStream.write(doFinal, 0, doFinal.length);
i2++;
i = i2 << 7;
} else {
byte[] byteArray = byteArrayOutputStream.toByteArray();
byteArrayOutputStream.close();
return byteArray;
}
}
} catch (Exception unused) {
return null;
}
}
}