Portable.Licensing how to associate a license with a PC

We have a C # application and it is necessary to protect it from illegal copying. Therefore, we decided to use the Portable.Licensing library to protect our system.

How can I bind a license to a hardware identifier in Portable.Licensing so that only a specific PC can use the license?

+6
source share
2 answers

You can create a unique hash by PC name, hardware information, etc. and add this hash as an Additional Attribute during license creation.

Example of creating a license:

 var license = License.New() .WithUniqueIdentifier(Guid.NewGuid()) .As(LicenseType.Standard) .WithMaximumUtilization(1) .WithAdditionalAttributes(new Dictionary<string, string> { {"HardwareId", "........"} }) .LicensedTo("John Doe", " john.doe@yourmail.here ") .CreateAndSignWithPrivateKey(privateKey, passPhrase); 

To test an attribute, you can implement your own validation extension method or just use the existing AssertThat() . Example: [1]

Generating a unique hardware identifier goes beyond portable licensing.

[1] https://github.com/dnauck/Portable.Licensing/blob/develop/src/Portable.Licensing/Validation/LicenseValidationExtensions.cs#L100

+7
source

You can call the AsserThat method:

 license.Validate() .AssertThat(lic => lic.ProductFeatures.Get("HardwareId") == "133456", new GeneralValidationFailure() { Message="Invalid Hardware.", HowToResolve="Contact administrator"}); 
+1
source

Source: https://habr.com/ru/post/988356/


All Articles