57 lines
1.9 KiB
Java
57 lines
1.9 KiB
Java
|
package o;
|
||
|
|
||
|
import android.text.TextUtils;
|
||
|
import com.google.common.primitives.UnsignedBytes;
|
||
|
import java.io.UnsupportedEncodingException;
|
||
|
import java.util.Locale;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public final class Yqs {
|
||
|
public static byte[] a(String str) {
|
||
|
if (TextUtils.isEmpty(str)) {
|
||
|
return new byte[0];
|
||
|
}
|
||
|
try {
|
||
|
String upperCase = str.toUpperCase(Locale.ENGLISH);
|
||
|
int length = upperCase.length() / 2;
|
||
|
byte[] bArr = new byte[length];
|
||
|
try {
|
||
|
byte[] bytes = upperCase.getBytes("UTF-8");
|
||
|
for (int i = 0; i < length; i++) {
|
||
|
StringBuilder sb = new StringBuilder();
|
||
|
sb.append("0x");
|
||
|
int i2 = i << 1;
|
||
|
sb.append(new String(new byte[]{bytes[i2]}, "UTF-8"));
|
||
|
byte byteValue = (byte) (Byte.decode(sb.toString()).byteValue() << 4);
|
||
|
StringBuilder sb2 = new StringBuilder();
|
||
|
sb2.append("0x");
|
||
|
sb2.append(new String(new byte[]{bytes[i2 + 1]}, "UTF-8"));
|
||
|
bArr[i] = (byte) (byteValue ^ Byte.decode(sb2.toString()).byteValue());
|
||
|
}
|
||
|
return bArr;
|
||
|
} catch (UnsupportedEncodingException | NumberFormatException e) {
|
||
|
e.getMessage();
|
||
|
return new byte[0];
|
||
|
}
|
||
|
} catch (Throwable th) {
|
||
|
th.getMessage();
|
||
|
return new byte[0];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static String b(byte[] bArr) {
|
||
|
if (bArr == null || bArr.length == 0) {
|
||
|
return "";
|
||
|
}
|
||
|
StringBuilder sb = new StringBuilder();
|
||
|
for (byte b : bArr) {
|
||
|
String hexString = Integer.toHexString(b & UnsignedBytes.MAX_VALUE);
|
||
|
if (hexString.length() == 1) {
|
||
|
sb.append('0');
|
||
|
}
|
||
|
sb.append(hexString);
|
||
|
}
|
||
|
return sb.toString();
|
||
|
}
|
||
|
}
|