软加密增加硬盘

master
yiming 3 years ago
parent 87118f89ca
commit abfa16c686

@ -22,6 +22,8 @@ public class LPLicense {
private static String CPU_INFO = null; private static String CPU_INFO = null;
private static String DISK_INFO = null;
/** /**
* *
*/ */
@ -30,7 +32,9 @@ public class LPLicense {
if(!file.exists()){ if(!file.exists()){
String cpu = getCpuInfo(); String cpu = getCpuInfo();
CPU_INFO = cpu; CPU_INFO = cpu;
FileUtil.save(cpu,key_path); String disk = getDiskInfo();
DISK_INFO = disk;
FileUtil.save(cpu+disk,key_path);
} }
} }
@ -44,7 +48,22 @@ public class LPLicense {
String cpu = sc.next(); String cpu = sc.next();
return cpu; return cpu;
} catch (IOException e) { } catch (IOException e) {
log.error("createLicKeyIfNotExist error:{}",e); log.error("GET CPU error:{}",e);
return null;
}
}
private static String getDiskInfo(){
try {
Process process = Runtime.getRuntime().exec(
new String[] { "wmic","diskdrive","where","index=0", "get", "serialnumber"});
process.getOutputStream().close();
Scanner sc = new Scanner(process.getInputStream());
String property = sc.next();
String disk = sc.next();
return disk;
} catch (IOException e) {
log.error("Get DISK error:{}",e);
return null; return null;
} }
} }
@ -55,12 +74,13 @@ public class LPLicense {
lastUpdate = LocalDateTime.now(); lastUpdate = LocalDateTime.now();
lic_str = FileUtil.getText(lic_path); lic_str = FileUtil.getText(lic_path);
CPU_INFO = getCpuInfo(); CPU_INFO = getCpuInfo();
DISK_INFO = getDiskInfo();
} }
return lic_str; return lic_str;
} }
public static boolean checkLic(String licStr){ public static boolean checkLic(String licStr){
return CPU_INFO != null && licStr.equals(encryptor.Encryptor.encryptStr(CPU_INFO)); return CPU_INFO != null && DISK_INFO != null && licStr.equals(encryptor.Encryptor.encryptStr(CPU_INFO+DISK_INFO));
} }
public static boolean checkLic(){ public static boolean checkLic(){

Loading…
Cancel
Save