diff --git a/app/libs/arm64-v8a/libpeko-common.so b/app/libs/arm64-v8a/libpeko-common.so new file mode 100644 index 000000000..cefd4d2f0 Binary files /dev/null and b/app/libs/arm64-v8a/libpeko-common.so differ diff --git a/app/libs/armeabi-v7a/libpeko-common.so b/app/libs/armeabi-v7a/libpeko-common.so new file mode 100644 index 000000000..53513f2f1 Binary files /dev/null and b/app/libs/armeabi-v7a/libpeko-common.so differ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4da441e94..c5290d6df 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1015,11 +1015,8 @@ - - - - + android:process=":core" + tools:node="remove"> - - - - + + + + + diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/utils/APIEncryptUtil.java b/core/src/main/java/com/yizhuan/xchat_android_core/utils/APIEncryptUtil.java index 18c60ad83..af7e33f7a 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/utils/APIEncryptUtil.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/utils/APIEncryptUtil.java @@ -24,16 +24,16 @@ public class APIEncryptUtil { private static final String DES_ENCRYPT_KEY_SMS_SIGN = XChatConstants.DES_ENCRYPT_KEY_SMS_SIGN; - /** - * 参数加密 - * @param params - * @return - * @throws Exception - */ - public static String encryptParams(Map params) throws Exception{ - String json = new Gson().toJson(params); - return DESUtils.DESAndBase64Encrypt(json,DES_ENCRYPT_KEY_SMS_PARAMS); - } +// /** +// * 参数加密 +// * @param params +// * @return +// * @throws Exception +// */ +// public static String encryptParams(Map params) throws Exception{ +// String json = new Gson().toJson(params); +// return DESUtils.DESAndBase64Encrypt(json,DES_ENCRYPT_KEY_SMS_PARAMS); +// } /** * 生成签名 diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/withdraw/WithdrawModel.java b/core/src/main/java/com/yizhuan/xchat_android_core/withdraw/WithdrawModel.java index d4efb0da0..42e1890bc 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/withdraw/WithdrawModel.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/withdraw/WithdrawModel.java @@ -118,7 +118,7 @@ public class WithdrawModel extends BaseModel implements IWithdrawModel { String paramsStr = null; String signStr = null; try { - paramsStr = APIEncryptUtil.encryptParams(paramsEncrypt); +// paramsStr = APIEncryptUtil.encryptParams(paramsEncrypt); signStr = APIEncryptUtil.paramsToSign(paramsEncrypt); } catch (Exception e) { e.printStackTrace(); diff --git a/library/src/main/java/com/yizhuan/xchat_android_library/utils/codec/DESUtils.java b/library/src/main/java/com/yizhuan/xchat_android_library/utils/codec/DESUtils.java index a7979cd75..5b419d71a 100644 --- a/library/src/main/java/com/yizhuan/xchat_android_library/utils/codec/DESUtils.java +++ b/library/src/main/java/com/yizhuan/xchat_android_library/utils/codec/DESUtils.java @@ -1,83 +1,19 @@ package com.yizhuan.xchat_android_library.utils.codec; -import android.util.Base64; - import com.yizhuan.xchat_android_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; - 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); + static { + System.loadLibrary("peko-common"); } - //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) { + return replaceBlank(stringFromJNI(replaceBlank(dataToEncrypt))); } public static String DESAndBase64(String psw) { @@ -100,42 +36,13 @@ public class DESUtils { return dest; } - //服务端解密 - public static String DESAndBase64Decrypt(String dataBase64) throws Exception { + public static String DESAndBase64Decrypt(String dataBase64) { 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 stringFromJNI2(dataBase64); } - /** - * 执行加密操作 - * - * @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); - } + public static native String stringFromJNI(String str); + + public static native String stringFromJNI2(String str); - /** - * 执行解密操作 - * - * @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); - } } \ No newline at end of file