|
@@ -25,7 +25,7 @@ public class RegCodeUtil {
|
|
* @return:
|
|
* @return:
|
|
**/
|
|
**/
|
|
public static String GenRegeditCode(String machineCode){
|
|
public static String GenRegeditCode(String machineCode){
|
|
- String s = Crypt.encryptAES(machineCode, true);
|
|
|
|
|
|
+ String s = Crypt.encryptAES(machineCode.trim(), true);
|
|
log.info("安装注册码:{}",s);
|
|
log.info("安装注册码:{}",s);
|
|
return s;
|
|
return s;
|
|
}
|
|
}
|
|
@@ -38,7 +38,7 @@ public class RegCodeUtil {
|
|
* @return:
|
|
* @return:
|
|
**/
|
|
**/
|
|
public static String GenRegeditCamCode(String plaintext){
|
|
public static String GenRegeditCamCode(String plaintext){
|
|
- String s = Crypt.encryptAES(plaintext, true);
|
|
|
|
|
|
+ String s = Crypt.encryptAES(plaintext.trim(), true);
|
|
log.info("相机注册码:{}",s);
|
|
log.info("相机注册码:{}",s);
|
|
log.info("相机注册码原始长度:{}",s.length());
|
|
log.info("相机注册码原始长度:{}",s.length());
|
|
String code = DeflaterUtil.zipString(s);
|
|
String code = DeflaterUtil.zipString(s);
|
|
@@ -56,7 +56,7 @@ public class RegCodeUtil {
|
|
**/
|
|
**/
|
|
public static MachineRegDto ParseMachineCode(String plaintext){
|
|
public static MachineRegDto ParseMachineCode(String plaintext){
|
|
try {
|
|
try {
|
|
- String source = Crypt.decryptAES(plaintext, true);
|
|
|
|
|
|
+ String source = Crypt.decryptAES(plaintext.trim(), true);
|
|
log.info("相机注册码解密:{}",source);
|
|
log.info("相机注册码解密:{}",source);
|
|
MachineRegDto t = JSON.toJavaObject(JSONObject.parseObject(source) , MachineRegDto.class);
|
|
MachineRegDto t = JSON.toJavaObject(JSONObject.parseObject(source) , MachineRegDto.class);
|
|
return t;
|
|
return t;
|
|
@@ -65,30 +65,30 @@ public class RegCodeUtil {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- /***
|
|
|
|
- * @description 获取激活数据
|
|
|
|
- * @author: Xiewj
|
|
|
|
- * @date: 2023/7/6 15:01
|
|
|
|
- * @param: plaintext 需要转换成对象的字符串
|
|
|
|
- * @return:
|
|
|
|
- **/
|
|
|
|
- public static CamRegDto ParseRegeditCamCode(String machineCode , String plaintext){
|
|
|
|
- try {
|
|
|
|
- //解压
|
|
|
|
- String code = DeflaterUtil.unzipString(plaintext);
|
|
|
|
- log.info("相机注册码解压:{}",code);
|
|
|
|
- String source = Crypt.decryptAES(code, true);
|
|
|
|
- log.info("相机注册码解密:{}",source);
|
|
|
|
- CamRegDto t = JSON.toJavaObject(JSONObject.parseObject(source) , CamRegDto.class);
|
|
|
|
- if (ObjUtil.isNull(t.getMachineCode()) && !t.getMachineCode().equals(machineCode)){
|
|
|
|
- throw new RuntimeException("校验失败");
|
|
|
|
- }
|
|
|
|
- return t;
|
|
|
|
- }catch (Exception e){
|
|
|
|
- e.printStackTrace();
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+// /***
|
|
|
|
+// * @description 获取激活数据
|
|
|
|
+// * @author: Xiewj
|
|
|
|
+// * @date: 2023/7/6 15:01
|
|
|
|
+// * @param: plaintext 需要转换成对象的字符串
|
|
|
|
+// * @return:
|
|
|
|
+// **/
|
|
|
|
+// public static CamRegDto ParseRegeditCamCode(String machineCode , String plaintext){
|
|
|
|
+// try {
|
|
|
|
+// //解压
|
|
|
|
+// String code = DeflaterUtil.unzipString(plaintext);
|
|
|
|
+// log.info("相机注册码解压:{}",code);
|
|
|
|
+// String source = Crypt.decryptAES(code, true);
|
|
|
|
+// log.info("相机注册码解密:{}",source);
|
|
|
|
+// CamRegDto t = JSON.toJavaObject(JSONObject.parseObject(source) , CamRegDto.class);
|
|
|
|
+// if (ObjUtil.isNull(t.getMachineCode()) && !t.getMachineCode().equals(machineCode)){
|
|
|
|
+// throw new RuntimeException("校验失败");
|
|
|
|
+// }
|
|
|
|
+// return t;
|
|
|
|
+// }catch (Exception e){
|
|
|
|
+// e.printStackTrace();
|
|
|
|
+// return null;
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
|
|
/***
|
|
/***
|
|
* @description:生成相机激活码多个
|
|
* @description:生成相机激活码多个
|
|
@@ -111,11 +111,11 @@ public class RegCodeUtil {
|
|
public static CamRegSDto BatchParseRegeditCamCode(String machineCode,String plaintext){
|
|
public static CamRegSDto BatchParseRegeditCamCode(String machineCode,String plaintext){
|
|
try {
|
|
try {
|
|
//解压
|
|
//解压
|
|
- String code = DeflaterUtil.unzipString(plaintext);
|
|
|
|
|
|
+ String code = DeflaterUtil.unzipString(plaintext.trim());
|
|
log.info("批量生成相机码解压:{}",code);
|
|
log.info("批量生成相机码解压:{}",code);
|
|
String source = Crypt.decryptAES(code, true);
|
|
String source = Crypt.decryptAES(code, true);
|
|
CamRegSDto t = JSON.toJavaObject(JSONObject.parseObject(source) , CamRegSDto.class);
|
|
CamRegSDto t = JSON.toJavaObject(JSONObject.parseObject(source) , CamRegSDto.class);
|
|
- if (ObjUtil.isNull(t.getMachineCode()) && !t.getMachineCode().equals(machineCode)){
|
|
|
|
|
|
+ if (ObjUtil.isNull(t.getMachineCode()) && !t.getMachineCode().equals(machineCode.trim())){
|
|
throw new RuntimeException("校验失败");
|
|
throw new RuntimeException("校验失败");
|
|
}
|
|
}
|
|
return t;
|
|
return t;
|
|
@@ -134,13 +134,13 @@ public class RegCodeUtil {
|
|
//生成安装注册码
|
|
//生成安装注册码
|
|
String s = GenRegeditCode(machineCode);
|
|
String s = GenRegeditCode(machineCode);
|
|
|
|
|
|
- CamRegDto camRegDto1=new CamRegDto();
|
|
|
|
- camRegDto1.setSn("00000001");
|
|
|
|
- camRegDto1.setMachineCode(machineCode);
|
|
|
|
- //生成相机注册码
|
|
|
|
- String camCode = GenRegeditCamCode( JSON.toJSONString(camRegDto1));
|
|
|
|
- //校验相机注册码
|
|
|
|
- CamRegDto camRegDto3 = ParseRegeditCamCode(machineCode,camCode);
|
|
|
|
|
|
+// CamRegDto camRegDto1=new CamRegDto();
|
|
|
|
+// camRegDto1.setSn("00000001");
|
|
|
|
+// camRegDto1.setMachineCode(machineCode);
|
|
|
|
+// //生成相机注册码
|
|
|
|
+// String camCode = GenRegeditCamCode( JSON.toJSONString(camRegDto1));
|
|
|
|
+// //校验相机注册码
|
|
|
|
+// CamRegDto camRegDto3 = ParseRegeditCamCode(machineCode,camCode);
|
|
|
|
|
|
|
|
|
|
List<CamRegDto> list=new ArrayList<>();
|
|
List<CamRegDto> list=new ArrayList<>();
|