Hardware ID generation
A hardware ID is a unique device identifier used to bind a license to that device, which helps to avoid transferring licenses to other devices.
This tutorial will help you learn more about hardware ID algorithms provided by LicenseSpring SDKs and choose the optimal hardware ID algorithm for your application.
Prerequisites
SDK-independent hardware ID generator library
We provide a SDK-independent hardware ID generator library as a dynamically-loadable shared library. This is a part of our on-going process to standardize licensing across all our SDKs. The library is integrated into:
C++ SDK since v7.42.0,
C# SDK since v7.34.0,
Java SDK since v2.25.1,
Go SDK since the v2 rewrite,
Python SDK since v2.0.0,
JavaScript SDK since initial release.
Swift and Android SDK use custom hardware ID generation algorithms as they are mostly tied to platforms with straightforward hardware ID generation.
Each SDK packages the shared library to be easily deployable either manually or through popular repositories and package managers. The library is released for multiple operating systems and architectures:
For Windows, we provide binaries built for x64, x86 and ARM64 architectures, built with a VS2022 MSVC toolchain. We also provide a version built GCC 8.1 from Qt's distribution of MinGW.
For macOS, we provide binaries built for the x86_64 architecture (min. required version 10.12) and arm64 architecture (min. required version 11.0).
For Linux, we provide binaries built for i686, x86_64, armv7l (i.e. armhf), ppc64le, s390x and riscv architectures, linked against either glibc 2.27 or musl libc.
For iOS, we provide an XCFramework, which includes slices for
iphoneos(arm64) andiphonesimulator(arm64 & x86_64). The slices are shipped as static libraries, which means the framework must be statically linked into the consumer library or application.
Algorithms list
The library exports an enum of available algorithms. Algorithm names in each SDK that FFIs into the library can easily be mapped to an algorithm in the following list:
The full package can be downloaded on the hardware ID generator download page.
Configuration
When you have chosen the algorithm, set it to the ExtendedOptions.
SDKs also allow overriding the hardware ID. For instance, you can use the MAC address as the hardware ID:
Relink License
The license relinking method can be useful when the hardware ID algorithm has been changed. Despite the license belonging to the current device, the local check will throw DeviceNotLicensedException since different algorithms produce different hardware IDs. In this case you can relink the license to the new hardware ID.
This method checks if the old hardware ID of the license matches any of the IDs generated by different algorithms. When it finds the correct algorithm, it deactivates the license with the old ID and activates it again using the new algorithm. This method throws the same exceptions as a regular license activation.
Recovering WMI
WMI repository issues can occur on Windows 10 and Windows 11. It's useful to know how to fix them since most of the hardware ID algorithms use WMI. Here are some recovery methods:
To check if the WMI repository is consistent, open Command Prompt with administrator privileges and run
winmgmt /verifyrepository. If you don't get a message statingWMI repository is consistent, proceed with the next steps.In the same Command Prompt window, run the three following commands:
cd C:\Windows\system32\wbemmofcomp.exe CIMWin32.mofregsvr32 cimwin32.dll
You can also try to recover WMI by running the following command from Command Prompt with admin privileges:
winmgmt /resetrepository. For more information, see https://stackoverflow.com/a/71535626
Be aware of risks of running the command above, see https://techcommunity.microsoft.com/t5/ask-the-performance-team/wmi-repository-corruption-or-not/ba-p/375484
Was this helpful?