Last active
February 12, 2025 03:13
-
-
Save ardzz/33fb255b3624440f3b3a63828c0d0343 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApiService{ | |
private final Headers.Builder getOkHttpHeaders(String str) { | |
Headers.Builder builder = new Headers.Builder(); | |
ProjectHeaders companion = ProjectHeaders.Companion.getInstance(); | |
Context context = this.mContext; | |
Intrinsics.checkNotNull(context); | |
for (Map.Entry<String, String> entry : companion.getHeaders(context).entrySet()) { | |
builder.addUnsafeNonAscii(entry.getKey(), entry.getValue()); | |
} | |
builder.add("X-IMI-UID", this.reqTime + "").add("X-IMI-NETWORK", this.mNetworkType + ""); | |
String str2 = builder.get(this.mChildHeaderKey); | |
if (str2 != null) { | |
builder.set(this.mChildHeaderKey, encryptMSISDN(str2)); | |
} | |
String str3 = this.mChildNumber; | |
if (str3 != null) { | |
builder.removeAll(this.mChildHeaderKey); | |
builder.add(this.mChildHeaderKey, encryptMSISDN(str3)); | |
} | |
if (this.noChild) { | |
builder.removeAll(this.mChildHeaderKey); | |
} | |
Pair<String, String> pair = this.mLocation; | |
if (pair != null) { | |
builder.add("X-LATITUDE", pair.getFirst()); | |
builder.add("X-LONGITUDE", pair.getSecond()); | |
} | |
addOkHttpSignature(str, builder); | |
addSecurityHash(builder); | |
return builder; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApiService{ | |
private final void addOkHttpSignature(String str, Headers.Builder builder) { | |
MixUpValues mixUpValues = new MixUpValues(); | |
String str2 = builder.get("X-IMI-TOKENID"); | |
if (str2 != null) { | |
builder.add("x-imi-oauth", mixUpValues.encryption("REQBODY=" + str + "&SALT=" + mixUpValues.getValues(StringsKt__StringsKt.trim((CharSequence) str2).toString()))); | |
} | |
} | |
private final void addSecurityHash(Headers.Builder builder) { | |
String str; | |
MixUpValues mixUpValues = new MixUpValues(); | |
if (builder.get(this.mChildHeaderKey) == null) { | |
str = "parent"; | |
} else { | |
str = String.valueOf(builder.get(this.mChildHeaderKey)); | |
} | |
builder.add("X-IMI-HASH", mixUpValues.encryption(str + Typography.dollar + builder.get("X-IMI-App-OS") + Typography.dollar + builder.get("X-IMI-VERSION") + Typography.dollar + builder.get("X-IMI-TOKENID") + "&SALT=" + mixUpValues.getValues("" + this.reqTime))); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.digitral.common; | |
import java.nio.charset.Charset; | |
import java.nio.charset.StandardCharsets; | |
import java.security.MessageDigest; | |
import kotlin.jvm.internal.Intrinsics; | |
import org.apache.commons.codec.digest.MessageDigestAlgorithms; | |
import org.jetbrains.annotations.NotNull; | |
/* loaded from: classes3.dex */ | |
public final class MixUpValues { | |
@NotNull | |
public final String getValues(@NotNull String id) { | |
Intrinsics.checkNotNullParameter(id, "id"); | |
int length = id.length(); | |
StringBuilder sb = new StringBuilder(); | |
int i = 1; | |
if (1 <= length) { | |
while (true) { | |
if (i % 2 != 0) { | |
sb.append(id.charAt(i - 1)); | |
} | |
if (i == length) { | |
break; | |
} | |
i++; | |
} | |
} | |
String sb2 = sb.toString(); | |
Intrinsics.checkNotNullExpressionValue(sb2, "builder.toString()"); | |
return sb2; | |
} | |
@NotNull | |
public final String encryption(@NotNull String string) { | |
Intrinsics.checkNotNullParameter(string, "string"); | |
MessageDigest messageDigest = MessageDigest.getInstance(MessageDigestAlgorithms.SHA_512); | |
Charset UTF_8 = StandardCharsets.UTF_8; | |
Intrinsics.checkNotNullExpressionValue(UTF_8, "UTF_8"); | |
byte[] bytes = string.getBytes(UTF_8); | |
Intrinsics.checkNotNullExpressionValue(bytes, "this as java.lang.String).getBytes(charset)"); | |
byte[] hash = messageDigest.digest(bytes); | |
StringBuilder sb = new StringBuilder(); | |
Intrinsics.checkNotNullExpressionValue(hash, "hash"); | |
for (byte b : hash) { | |
String hexString = Integer.toHexString(b & 255); | |
if (hexString.length() == 1) { | |
sb.append('0'); | |
} | |
sb.append(hexString); | |
} | |
String sb2 = sb.toString(); | |
Intrinsics.checkNotNullExpressionValue(sb2, "hexString.toString()"); | |
return sb2; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment