2.1 注册PDA的信息存储到文件内部,采取mac+固定加密串的MD5加密校验
This commit is contained in:
@ -11,7 +11,7 @@ android {
|
||||
minSdk 28
|
||||
targetSdk 28
|
||||
versionCode 1
|
||||
versionName "1.19"
|
||||
versionName "2.1"
|
||||
|
||||
// 1.0 IDATA广播模式处理
|
||||
// 1.1 霍尼韦尔的监听修改(扫描网站二维码跳出程序,监听失效,调整)、斑马PDA广播模式设置
|
||||
@ -33,6 +33,7 @@ android {
|
||||
// 1.17 霍尼韦尔EDA51、EDA50P,调用扫描枪的方法,在关闭的时候停止调用扫描枪
|
||||
// 1.18 瑞兴平板,读取扫描结果,使用同步加锁模式
|
||||
// 1.19 index页面接入初始化数据
|
||||
// 2.1 注册PDA的信息存储到文件内部,采取mac+固定加密串的MD5加密校验
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
ndk {
|
||||
abiFilters 'armeabi-v7a'
|
||||
|
||||
@ -2,8 +2,8 @@ package chaoran.business.utils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.bluetooth.le.ScanSettings;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
@ -18,13 +18,12 @@ import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import chaoran.business.BrandEnum;
|
||||
import chaoran.business.BuildConfig;
|
||||
import chaoran.business.R;
|
||||
import chaoran.business.activity.MainActivity;
|
||||
|
||||
public class LocalAddressUtil {
|
||||
|
||||
public final static String SSO_KEY = "!~CROP@CRTECH@PDA~!";
|
||||
|
||||
private Context context;
|
||||
|
||||
private Activity activity;
|
||||
@ -160,6 +159,32 @@ public class LocalAddressUtil {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("JavascriptInterface")
|
||||
@JavascriptInterface
|
||||
public String registerMac(String applyMac) {
|
||||
try {
|
||||
String mac = this.getMacAddress();
|
||||
String md5Hash = MD5.md5(mac + SSO_KEY);
|
||||
if (md5Hash != null && md5Hash.equals(applyMac)) {
|
||||
// 将允许注册适配的mac写入文件中
|
||||
SharedPreferences.Editor editor = context.getSharedPreferences("CrtechPdaConfig", Context.MODE_PRIVATE).edit();
|
||||
editor.putString("checkMac", "success");
|
||||
editor.commit();
|
||||
return "success";
|
||||
}
|
||||
}catch (Exception ignored) {
|
||||
|
||||
}
|
||||
return "error";
|
||||
}
|
||||
|
||||
@SuppressLint("JavascriptInterface")
|
||||
@JavascriptInterface
|
||||
public String checkMacRegister() {
|
||||
SharedPreferences sharedPreferences = context.getSharedPreferences("CrtechPdaConfig", Context.MODE_PRIVATE);
|
||||
return sharedPreferences.getString("checkMac", "error");
|
||||
}
|
||||
|
||||
@SuppressLint("JavascriptInterface")
|
||||
@JavascriptInterface
|
||||
public String getApkVersion() {
|
||||
|
||||
34
app/src/main/java/chaoran/business/utils/MD5.java
Normal file
34
app/src/main/java/chaoran/business/utils/MD5.java
Normal file
@ -0,0 +1,34 @@
|
||||
package chaoran.business.utils;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
// 从框架的MD5加密类拷贝过来的
|
||||
public class MD5 {
|
||||
private static final String key = "aa";
|
||||
private static final char[] hexDigits = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
||||
|
||||
public static final String md5(String s) {
|
||||
return s == null ? null : md5(s.getBytes());
|
||||
}
|
||||
|
||||
public static final String md5(byte[] bytes) {
|
||||
try {
|
||||
MessageDigest mdTemp = MessageDigest.getInstance("MD5");
|
||||
mdTemp.update(bytes);
|
||||
byte[] md = mdTemp.digest();
|
||||
int j = md.length;
|
||||
char[] str = new char[j * 2];
|
||||
int k = 0;
|
||||
|
||||
for(int i = 0; i < j; ++i) {
|
||||
byte byte0 = md[i];
|
||||
str[k++] = hexDigits[byte0 >>> 4 & 15];
|
||||
str[k++] = hexDigits[byte0 & 15];
|
||||
}
|
||||
|
||||
return new String(str);
|
||||
} catch (Exception var8) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user