feat:修改加密方案(换so方式)
feat:调整混淆配置 feat:补充部分场景log
This commit is contained in:
5
app/proguard-rules.pro
vendored
5
app/proguard-rules.pro
vendored
@@ -185,6 +185,11 @@
|
||||
# for DexGuard only
|
||||
#-keepresourcexmlelements manifest/application/meta-data@value=GlideModule
|
||||
|
||||
# Presenter 相关
|
||||
-keep class com.chwl.app.base.** { *; }
|
||||
-keep public class * extends com.chwl.app.base.BaseMvpPresenter
|
||||
-keep public class * extends com.chwl.library.base.factory.AbstractMvpPresenter
|
||||
|
||||
# BaseAdapter
|
||||
-keep class com.chad.library.adapter.** {
|
||||
*;
|
||||
|
@@ -249,7 +249,6 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
mMainTabLayout.setMainTabInfoList(mainTabInfo);
|
||||
}
|
||||
});
|
||||
InitialModel.get().regionCheck();
|
||||
//检测更新
|
||||
AppUpgradeHelper.checkAppUpgrade(this);
|
||||
initMaterialView();
|
||||
@@ -517,6 +516,7 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onLoadLoginUserInfoEvent(LoadLoginUserInfoEvent event) {
|
||||
firstLoadedUserInfo();
|
||||
InitialModel.get().regionCheck();
|
||||
}
|
||||
|
||||
public void onLogout() {
|
||||
|
@@ -198,10 +198,11 @@ public class App extends BaseApp {
|
||||
|
||||
String channel = "";
|
||||
channel = ChannelReaderUtil.getChannel(instance);
|
||||
Log.d("APP", "localChannel:" + channel);
|
||||
if (TextUtils.isEmpty(channel)) {
|
||||
channel = Constants.GOOGLE;
|
||||
}
|
||||
|
||||
Log.d("APP", "finalChannel:" + channel);
|
||||
BasicConfig.INSTANCE.setOriginalChannel(channel);
|
||||
|
||||
BasicConfig.INSTANCE.setChannel(channel);
|
||||
|
@@ -205,6 +205,7 @@ public class ChargeActivity extends BaseMvpActivity<IChargeView, ChargePresenter
|
||||
}
|
||||
runOnUiThread(() -> mChargeAdapter.setNewData(showChargeList));
|
||||
} else {
|
||||
Log.d(TAG, "initProduceList() 0");
|
||||
getDialogManager().dismissDialog();
|
||||
toast(getString(R.string.Recharge_failure));
|
||||
}
|
||||
@@ -219,6 +220,7 @@ public class ChargeActivity extends BaseMvpActivity<IChargeView, ChargePresenter
|
||||
for (IPurchase purchase : purchases) {
|
||||
if (purchase.isPurchasedState() &&
|
||||
purchase.getAccountIdentifiers() != null) {
|
||||
Log.d(TAG, "onPurchasesUpdated() verifyOrder");
|
||||
PayModel.get().verifyOrder(
|
||||
purchase.getAccountIdentifiers().getObfuscatedAccountId(),
|
||||
purchase.getProducts().get(0),
|
||||
@@ -274,10 +276,13 @@ public class ChargeActivity extends BaseMvpActivity<IChargeView, ChargePresenter
|
||||
return;
|
||||
}
|
||||
if (productDetails != null) {
|
||||
Log.d(TAG, "BuyProduct:" + productDetails.getProductId());
|
||||
Log.d(TAG, "buyProduct():" + productDetails.getProductId());
|
||||
PayModel.get().placeOrder(productDetails.getProductId())
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(recordId -> billingManager.initiatePurchaseFlow(productDetails, recordId.getRecordId()),
|
||||
.subscribe(recordId -> {
|
||||
Log.d(TAG, "buyProduct() rid:" + recordId);
|
||||
billingManager.initiatePurchaseFlow(productDetails, recordId.getRecordId());
|
||||
},
|
||||
throwable -> {
|
||||
if (throwable instanceof FailReasonException) {
|
||||
FailReasonException failReasonException = (FailReasonException) throwable;
|
||||
|
@@ -3,17 +3,21 @@ package com.chwl.core
|
||||
import com.chwl.library.utils.codec.DESUtils
|
||||
|
||||
object SdkConfig {
|
||||
fun getTXAppId() = decrypt("FWVTBRkBKfYufNwqvQJdTw==")
|
||||
// 1400823228
|
||||
fun getTXAppId() = decrypt("cTkOfnb3r7vaFs4wfq3Aog==")
|
||||
|
||||
fun getAgoraKey() = decrypt("nG0ISOgixMxTjvSf2k0cAEPQkPiBOFbl0pXN90FFYNBzztbmqRnI4g==")
|
||||
// f8713b6ec98c4c01adaf34cb4fa091b1
|
||||
fun getAgoraKey() = decrypt("PeyLUWRgKCvpEoCfS4N7e0ME1EFveAxP8/ghtNgvAappYKlmIfzkBA==")
|
||||
|
||||
fun getNimKeyDebug() = decrypt("1Gb6Qra5ozRKY1/y4NCrTl0DUqrpq2zL8MVAvQAfYUtzztbmqRnI4g==")
|
||||
// 1c3b8c6bf8467d8e4c33a004dbec5c94
|
||||
fun getNimKeyDebug() = decrypt("I3U3e6/lM156ggnsyDmOpPQ48hiEUXk4aTqy5Vc3WeNpYKlmIfzkBA==")
|
||||
|
||||
fun getNimKeyRelease() = decrypt("dpXJwHVETO/GJEy0z5179Xd2rRRSIc1OFTZ+PzvYyelzztbmqRnI4g==")
|
||||
// d4d74e9ba6ac3364ccc7526ea4791215
|
||||
fun getNimKeyRelease() = decrypt("q5VJ2Q0uLeCNdEGWurSgcgDEwO+qDzpEKFhnkvRacPlpYKlmIfzkBA==")
|
||||
|
||||
private fun decrypt(value: String): String {
|
||||
return try {
|
||||
DESUtils.DESAndBase64Decrypt("2ea53d260ecf21e7b56e00223e042226", value)
|
||||
DESUtils.decryptDef2(value)
|
||||
} catch (e: Exception) {
|
||||
""
|
||||
}
|
||||
|
@@ -419,8 +419,6 @@ public final class UserModel extends BaseModel implements IUserModel {
|
||||
EventBus.getDefault().post(new CurrentUserInfoCompleteEvent());
|
||||
//完善资料后,登录流程结束,发出加载事件
|
||||
EventBus.getDefault().post(new LoadLoginUserInfoEvent());
|
||||
// 地区检测
|
||||
InitialModel.get().regionCheck();
|
||||
})
|
||||
.doOnError(throwable -> {
|
||||
EventBus.getDefault().post(new CurrentUserInfoCompleteFailEvent(throwable.getMessage()));
|
||||
|
@@ -32,8 +32,8 @@ COMPILE_SDK_VERSION=33
|
||||
MIN_SDK_VERSION=21
|
||||
TARGET_SDK_VERSION=33
|
||||
|
||||
version_name=3.3.0
|
||||
version_code=3300
|
||||
version_name=10.0.0
|
||||
version_code=10005
|
||||
|
||||
#systemProp.https.proxyHost=127.0.0.1
|
||||
#systemProp.https.proxyPort=7890
|
||||
|
@@ -44,7 +44,6 @@ android {
|
||||
'src/module_common/res',
|
||||
|
||||
]
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,6 +119,7 @@ dependencies {
|
||||
|
||||
api project(':libs:lib_utils')
|
||||
api project(':libs:lib_core')
|
||||
api project(':libs:lib_encrypt')
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@@ -1,83 +1,15 @@
|
||||
package com.chwl.library.utils.codec;
|
||||
|
||||
import android.util.Base64;
|
||||
|
||||
import com.chwl.library.utils.StringUtils;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.Key;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.SecretKeyFactory;
|
||||
import javax.crypto.spec.DESKeySpec;
|
||||
|
||||
//import sun.misc.BASE64Decoder;
|
||||
//import sun.misc.BASE64Encoder;
|
||||
import com.example.lib_encrypt.EncryptLib;
|
||||
|
||||
|
||||
public class DESUtils {
|
||||
|
||||
// static BASE64Decoder decoder = new BASE64Decoder();
|
||||
// static BASE64Encoder encoder = new BASE64Encoder();
|
||||
|
||||
static String DES = "DES";
|
||||
static String ENCODE = "UTF-8";//保持平台兼容统一使用utf-8
|
||||
|
||||
//des 加密
|
||||
private static byte[] encryptByteDES(byte[] byteD, String strKey) throws Exception {
|
||||
return doEncrypt(byteD, getKey(strKey), DES);
|
||||
}
|
||||
|
||||
//des 解密
|
||||
private static byte[] decryptByteDES(byte[] byteD, String strKey) throws Exception {
|
||||
return doDecrypt(byteD, getKey(strKey), DES);
|
||||
}
|
||||
|
||||
public static SecretKey getKey(String strKey) throws Exception {
|
||||
DESKeySpec desKeySpec = new DESKeySpec(strKey.getBytes());
|
||||
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(DES);
|
||||
SecretKey sk = keyFactory.generateSecret(desKeySpec);
|
||||
return sk;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
String text = "admin";
|
||||
// String pwd = "NJD783iSDK0d9fjd98KKDf9O";
|
||||
String pwd = "1ea53d260ecf11e7b56e00163e046a26";
|
||||
//客户端加密
|
||||
// String data = DESAndBase64Encrypt(text, pwd);
|
||||
// System.out.println(ResUtil.getString(R.string.utils_codec_desutils_01) + URLEncoder.encode(data, "UTF-8"));
|
||||
|
||||
//服务端解密
|
||||
// String textDecrypt = DESAndBase64Decrypt(data, pwd);
|
||||
// System.out.println(ResUtil.getString(R.string.utils_codec_desutils_02) + text);
|
||||
// System.out.println(ResUtil.getString(R.string.utils_codec_desutils_03) + textDecrypt);
|
||||
|
||||
|
||||
// byte[] bytes = text.getBytes();
|
||||
// byte[] encode = Base64.encode(bytes,Base64.DEFAULT);
|
||||
|
||||
}
|
||||
|
||||
//客户端加密
|
||||
public static String DESAndBase64Encrypt(String dataToEncrypt, String secretKey) throws Exception {
|
||||
byte[] encryptData = encryptByteDES(dataToEncrypt.getBytes(ENCODE), secretKey);//这里加密前不要处理加密数据的空格换行等事情
|
||||
byte[] encode = Base64.encode(encryptData, Base64.DEFAULT);
|
||||
String dataBase64 = StringUtils.toEncodedString(encode, Charset.defaultCharset());
|
||||
return replaceBlank(dataBase64);
|
||||
}
|
||||
|
||||
//客户端加密
|
||||
public static String DESAndBase64Encrypt(String dataToEncypt) throws Exception {
|
||||
byte[] encryptData = encryptByteDES(replaceBlank(dataToEncypt).getBytes(ENCODE), "1ea53d260ecf11e7b56e00163e046a26");
|
||||
byte[] encode = Base64.encode(encryptData, Base64.DEFAULT);
|
||||
String dataBase64 = StringUtils.toEncodedString(encode, Charset.defaultCharset());
|
||||
return replaceBlank(dataBase64);
|
||||
public static String DESAndBase64Encrypt(String dataToEncrypt) throws Exception {
|
||||
return EncryptLib.INSTANCE.encryptTextDef1(dataToEncrypt);
|
||||
}
|
||||
|
||||
public static String DESAndBase64(String psw) {
|
||||
@@ -90,62 +22,16 @@ public class DESUtils {
|
||||
return pwd;
|
||||
}
|
||||
|
||||
public static String replaceBlank(String str) {
|
||||
String dest = "";
|
||||
if (str != null) {
|
||||
Pattern p = Pattern.compile("\\s*|\t|\r|\n");
|
||||
Matcher m = p.matcher(str);
|
||||
dest = m.replaceAll("");
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
//服务端解密
|
||||
public static String DESAndBase64Decrypt(String dataBase64) throws Exception {
|
||||
if (StringUtils.isEmpty(dataBase64)) return null;
|
||||
byte[] encryptedData = Base64.decode(dataBase64, Base64.DEFAULT);
|
||||
byte[] decryptedData = decryptByteDES(encryptedData, "1ea53d260ecf11e7b56e00163e046a26");
|
||||
String textDecrypt = new String(decryptedData, ENCODE);
|
||||
return textDecrypt;
|
||||
return EncryptLib.INSTANCE.decryptTextDef1(dataBase64);
|
||||
}
|
||||
|
||||
|
||||
//服务端解密
|
||||
public static String DESAndBase64Decrypt(String key,String dataBase64) throws Exception {
|
||||
//解密
|
||||
public static String decryptDef2(String dataBase64) throws Exception {
|
||||
if (StringUtils.isEmpty(dataBase64)) return null;
|
||||
byte[] encryptedData = Base64.decode(dataBase64, Base64.DEFAULT);
|
||||
byte[] decryptedData = decryptByteDES(encryptedData, key);
|
||||
String textDecrypt = new String(decryptedData, ENCODE);
|
||||
return textDecrypt;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行加密操作
|
||||
*
|
||||
* @param data 待操作数据
|
||||
* @param key Key
|
||||
* @param type 算法 RSA or DES
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private static byte[] doEncrypt(byte[] data, Key key, String type) throws Exception {
|
||||
Cipher cipher = Cipher.getInstance(type);
|
||||
cipher.init(Cipher.ENCRYPT_MODE, key);
|
||||
return cipher.doFinal(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行解密操作
|
||||
*
|
||||
* @param data 待操作数据
|
||||
* @param key Key
|
||||
* @param type 算法 RSA or DES
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private static byte[] doDecrypt(byte[] data, Key key, String type) throws Exception {
|
||||
Cipher cipher = Cipher.getInstance(type);
|
||||
cipher.init(Cipher.DECRYPT_MODE, key);
|
||||
return cipher.doFinal(data);
|
||||
return EncryptLib.INSTANCE.decryptTextDef2(dataBase64);
|
||||
}
|
||||
}
|
1
libs/lib_encrypt/.gitignore
vendored
Normal file
1
libs/lib_encrypt/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
15
libs/lib_encrypt/build.gradle
Normal file
15
libs/lib_encrypt/build.gradle
Normal file
@@ -0,0 +1,15 @@
|
||||
apply from : "../lib_standard.gradle"
|
||||
|
||||
android {
|
||||
namespace 'com.example.lib_encrypt'
|
||||
|
||||
sourceSets{
|
||||
main{
|
||||
jniLibs.srcDirs = ['libs']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api "androidx.core:core-ktx:1.9.0"
|
||||
}
|
0
libs/lib_encrypt/consumer-rules.pro
Normal file
0
libs/lib_encrypt/consumer-rules.pro
Normal file
BIN
libs/lib_encrypt/libs/arm64-v8a/libencrypt.so
Executable file
BIN
libs/lib_encrypt/libs/arm64-v8a/libencrypt.so
Executable file
Binary file not shown.
BIN
libs/lib_encrypt/libs/armeabi-v7a/libencrypt.so
Executable file
BIN
libs/lib_encrypt/libs/armeabi-v7a/libencrypt.so
Executable file
Binary file not shown.
BIN
libs/lib_encrypt/libs/x86/libencrypt.so
Executable file
BIN
libs/lib_encrypt/libs/x86/libencrypt.so
Executable file
Binary file not shown.
BIN
libs/lib_encrypt/libs/x86_64/libencrypt.so
Executable file
BIN
libs/lib_encrypt/libs/x86_64/libencrypt.so
Executable file
Binary file not shown.
21
libs/lib_encrypt/proguard-rules.pro
vendored
Normal file
21
libs/lib_encrypt/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
4
libs/lib_encrypt/src/main/AndroidManifest.xml
Normal file
4
libs/lib_encrypt/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
</manifest>
|
@@ -0,0 +1,58 @@
|
||||
package com.example.lib_encrypt
|
||||
|
||||
import java.util.regex.Pattern
|
||||
|
||||
object EncryptLib {
|
||||
|
||||
init {
|
||||
System.loadLibrary("encrypt")
|
||||
}
|
||||
|
||||
fun encryptText(enc: String, key: String): String {
|
||||
return replaceBlank(encrypt(replaceBlank(enc), key) ?: "")
|
||||
}
|
||||
|
||||
fun decryptText(dec: String, key: String): String {
|
||||
return decrypt(dec, key) ?: ""
|
||||
}
|
||||
|
||||
fun encryptTextDef1(enc: String): String {
|
||||
return replaceBlank(encryptDef(replaceBlank(enc)) ?: "")
|
||||
}
|
||||
|
||||
fun decryptTextDef1(dec: String): String {
|
||||
return decryptDef(dec) ?: ""
|
||||
}
|
||||
|
||||
fun encryptTextDef2(enc: String): String {
|
||||
return replaceBlank(encryptDef2(replaceBlank(enc)) ?: "")
|
||||
}
|
||||
|
||||
fun decryptTextDef2(dec: String): String {
|
||||
return decryptDef2(dec) ?: ""
|
||||
}
|
||||
|
||||
private fun replaceBlank(str: String): String {
|
||||
val p = Pattern.compile("\\s*|\t|\r|\n")
|
||||
val m = p.matcher(str)
|
||||
return m.replaceAll("")
|
||||
}
|
||||
|
||||
// DES
|
||||
private external fun encrypt(enc: String, key: String): String?
|
||||
|
||||
// DES
|
||||
private external fun decrypt(dec: String, key: String): String?
|
||||
|
||||
// DES-默认KEY1
|
||||
private external fun encryptDef(enc: String): String?
|
||||
|
||||
// DES-默认KEY1(1ea53d26)
|
||||
private external fun decryptDef(dec: String): String?
|
||||
|
||||
// DES-默认KEY2
|
||||
private external fun encryptDef2(enc: String): String?
|
||||
|
||||
// DES-默认KEY2(9fa73e66)
|
||||
private external fun decryptDef2(dec: String): String?
|
||||
}
|
@@ -10,3 +10,4 @@ include ':modules:module_base'
|
||||
include ':libs:lib_core'
|
||||
include ':libs:lib_utils'
|
||||
include ':libs:lib_crop'
|
||||
include ':libs:lib_encrypt'
|
||||
|
Reference in New Issue
Block a user