SDKs
...
Best Practices
Hardware ID generation
7 min
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 completed the getting started docid\ lsfy9tq3vfq4roow9shkd tutorial, including initialized licensemanager (or licensehandler ) with your configuration using the appropriate settings activated a license of any type implemented routine local and online checks within the application 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 to be released, 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 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 licensespring extendedoptions options; // deviceidalgorithm hardwareidgeneratordefault is the default // value for the new hardware id generator library options setdeviceidalgorithm(hardwareidgeneratordefault);var options = new extendedoptions(); options deviceidalgorithm = deviceidalgorithm autoid;configuration hardwareid = generatemyowncustomid()licensespringconfiguration config = licensespringconfiguration builder() identityprovider(hardwareidstrategy auto hardware id) build(); sdks also allow overriding the hardware id for instance, you can use the mac address as the hardware id licensespring extendedoptions options; options sethardwareid( options getnetworkinfo() mac() );var configuration = new licensespring configuration(); var options = new licensespring extendedoptions(); options hardwareid = configuration macaddress; configuration extendedoptions = options;// go sdk v2 lm config = license manager licensemanagerbasicconfiguration{ 	 oauth false, 	 apikey "your api key", 	 sharedkey "your shared key", 	 productcode "your product code", 	 authdata auth fromkey("license key"), 	 } lm, = license manager newlicensemanager( lm config, license manager withhardwareid("your hw id"), )licensespringconfiguration config = licensespringconfiguration builder() identityprovider(customidentityprovider) build(); 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 try { license >localcheck(); } catch(const devicenotlicensedexception& ex) { std cout << "trying to upgrade to newer hardware id algorithm " << std endl; license = m licensemanager >relinklicense(hardwareidgeneratorwindowscomputersystemproductid); std cout << "license successfully linked to new hardware id " << std endl; return; } // the c++ sdk also provides unlinkfromdevice and islicensebelongstothisdevice methods // unlinkfromdevice check if the license is tied to the current device, and deactivates it // islicensebelongstothisdevice checks if the license belongs to hardware id computed by // the passed deviceidalgorithmtry { license localcheck(); } catch( devicenotlicensedexception ex ) { console writeline( "trying to upgrade to a newer device id algorithm " ); license = manager relinklicense( deviceidalgorithm gen3 ); console writeline( "license successfully linked to new device id \n" ); return; } 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 stating wmi repository is consistent , proceed with the next steps in the same command prompt window, run the three following commands cd c \windows\system32\wbem mofcomp exe cimwin32 mof regsvr32 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 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 https //techcommunity microsoft com/t5/ask the performance team/wmi repository corruption or not/ba p/375484