SDKs
...
Tutorials
Best Practices
Hardware ID
12min
hardware id is a unique device identifier used to activate a license it is important value that helps to link a license to a device and avoid transferring licenses to other devices this tutorial will help you learn more about device id algorithms provided by the licensespring sdk and choose the optimal device 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 hardware id algorithms default algorithm windows default device id uses wmi to get model, manufacturer, name, serialnumber of the motherboard, processor and disc drive then it encodes these values to provide a unique string that represents the current device linux default device id reads the machine id from the /etc/machine id file this file contains the unique machine id of the local system that is set during installation or boot if this id is not found, it tries to read the /var/lib/dbus/machine id file if it still fails to get the id, it writes a generated uuid macos the c++ sdk uses the gethostuuid() system call to get a unique identifier of the device the net sdk gets ioplatformuuid value swift swift sdk uses machine uuid in macos sdk and uidevice current identifierforvendor in ios sdk windows algorithms c++ sdk gen2 algorithm is similar to the default algorithm it is safer and shorter than default this algorithm retrieves the manufacturer and serialnumber of the motherboard, cpu name and id, and disc model and serial number this algorithm can be useful for air gap licenses wincsproductid is an alternative algorithm for windows it gets the uuid of the windows machine using computer system product id through wmi wincryptographyid is an algorithm for windows that doesn't use wmi it gets microsoft cryptography machineguid from windows registry net sdk gen1 includes minor improvements for id calculation on windows, on other platforms the same as default gen2 and gen3 are safer device id algorithms on windows, on other platforms the same as default gen3 is a shorter form that can be useful for air gap licenses winalternative algorithm tries to get microsoft cryptography machineguid from windows registry if this request fails or net framework version is earlier than 4 0, it tries to get the uuid of the windows machine using computer system product id cloud platform algorithms cloudplatformsid is useful when the software runs on azure , aws or gcp it is a good option when the application will be used only on these platforms if the application can be installed on other platforms as well, the autoid algorithm should be used autoid uses different approaches depending on your platform if the application is running on azure, aws or gcp, it is the same as cloudplatformsid , otherwise the same as default autoidwincloud also uses different platform dependent approaches if the application is running on azure, aws or gcp, it is the same as cloudplatformsid , otherwise the same as wincsproductid this algorithm should only be used on windows computers hardware id usage configuration when you have chosen the algorithm, set it to the extendedoptions licensespring extendedoptions options; options setdeviceidalgorithm( autoid );var options = new extendedoptions(); options deviceidalgorithm = deviceidalgorithm autoid;configuration hardwareid = generatemyowncustomid() net sdk allows to specify the timeout for cloud platforms id requests it is useful when autoid takes too long on a regular machine this value is specified in milliseconds, the default is 200 options cloudidrequesttimeout = 100; the sdk allows overriding 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"), ) relink license the relink license method can be useful when the device algorithm has been changed despite the license belongs to the device, local check will throw devicenotlicensedexception since the device ids don’t match in this case you can relink the license to the new id try { license >localcheck(); } catch( const devicenotlicensedexception& ex ) { std cout << "trying to upgrade to newer device id algorithm " << std endl; license = m licensemanager >relinklicense( wincryptographyid ); std cout << "license successfully linked to new device id " << std endl; return; }try { 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 device id of the license matches any of the ids generated by different algorithms when it finds the correct option, 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 c++ sdk provides unlinkfromdevice and islicensebelongstothisdevice methods the first one checks if the license belongs to this device and deactivates it it may throw the same exceptions as the deactivate method the islicensebelongstothisdevice method checks if the license belongs to the provided deviceidalgorithm on this machine recovering wmi on windows 11/10 wmi repository issues can occur it is good to know how to fix them since most of the device id algorithms use wmi here are a couple of ways to recover wmi service to check if the wmi repository is consistent, the open command prompt with admin 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 admin 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 informed about the risks of running the command above, for more information 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