Serial Key Generation and Validation in Java (Machine Unique Identifier)
-
06-12-2019 - |
题
I have to protect with a validation Key an application written in Java, the key should work only on a specified PC, so for example a machine ID serial number should be generated by the application based on a unique identifier (for example : hard disk serial, MainBoard serial and so on ... ); then based on this unique identifier another program will generate a validation key.
I have already implemented a similar activation system on a .NET application generating Machine identifier, getting hardware serial numbers from WMI, How can i get this values in Java ? The solution should work independently on Windows, Linux and Mac Os X .
How can i retrieve a unique identifier of a machine in Java ? Is there some library out there, that allow to do it ?
解决方案
The machines MAC address (or one of the machines MAC addresses) is a good candidate. It is unique and probably changes less often then other hardware identifiers. Here's a code snippet:
其他提示
I dont think you can get CPU Id or Harddisk/motherboard Ids in pure java. The closest you have is network mac address:
NetworkInterface.getNetworkInterfaces().nextElement().getHardwareAddress();
You need to call something platform specific. For example on Windows you can call a VB script which calls the WMI to get this information.
Note: what ever approach you use should be easy to fool if you know what you are doing.