package com.baidu.liantian.utility; import android.content.Context; import android.text.TextUtils; import android.util.Base64; import com.baidu.idl.face.platform.FaceEnvironment; import com.baidu.liantian.ac.F; import com.baidu.liantian.ac.RequestInfo; import com.sigmob.sdk.base.mta.PointCategory; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.util.Random; import org.json.JSONObject; /* compiled from: EncryptConnFaceServerUtil */ public final class c { public static RequestInfo a(Context context, String str, byte[] bArr, String str2) throws Throwable { byte[] bArr2; char[] charArray = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray(); char[] cArr = new char[16]; for (int i = 0; i < 16; i++) { cArr[i] = charArray[new Random().nextInt(62)]; } byte[] bytes = new String(cArr).getBytes(); if (!TextUtils.isEmpty(str)) { ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(str.getBytes()); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); f.a(byteArrayInputStream, byteArrayOutputStream); byte[] byteArray = byteArrayOutputStream.toByteArray(); byteArrayOutputStream.flush(); byteArrayOutputStream.close(); byteArrayInputStream.close(); bArr2 = F.getInstance().ae(byteArray, bytes); } else { bArr2 = "".getBytes(); } JSONObject jSONObject = new JSONObject(); jSONObject.put("data", Base64.encodeToString(bArr2, 0).replace("\n", "").replace("\t", "").replace("\r", "")); jSONObject.put(PointCategory.APP, FaceEnvironment.OS); String encodeToString = Base64.encodeToString(F.getInstance().re(bytes, h.a(b.b(context)).getBytes()), 0); String a = h.a(b.b(context)); if (bArr == null || bArr.length == 0 || TextUtils.isEmpty(str2)) { return new RequestInfo(encodeToString, a, jSONObject); } byte[] ae = F.getInstance().ae(WbEncryptUtil.wbEncrypt(context, bArr), bytes); File file = new File(str2); if (file.exists() && file.isFile()) { file.delete(); } if (!file.exists()) { file.mkdirs(); } File file2 = new File(file, "tmp_v_" + System.currentTimeMillis()); if (a.a(context, ae, file2)) { return new RequestInfo(encodeToString, a, jSONObject, file2.getAbsolutePath()); } throw new RuntimeException("Wirte File Error."); } }