使用代码:

Easy License 非常容易使用,为了验证一个软件,你需要下面3个步骤。

1: Create apublic/privateKey.

1234567891011121314151617if(File.Exists("privateKey.xml") || File.Exists("publicKey.xml")){varresult = MessageBox.Show("The key is existed, override it?","Warning", MessageBoxButton.YesNo);if(result == MessageBoxResult.No){return;}}varprivateKey ="";varpublicKey ="";LicenseGenerator.GenerateLicenseKey(outprivateKey,outpublicKey);File.WriteAllText("privateKey.xml", privateKey);File.WriteAllText("publicKey.xml", publicKey);MessageBox.Show("The Key is created, please backup it.");

  

2: Useprivatekey to create a license

1234567891011121314151617if(!File.Exists("privateKey.xml")){MessageBox.Show("Pleasecreatealicensekeyfirst");return;}varprivateKey=File.ReadAllText(@"privateKey.xml");vargenerator=newLicenseGenerator(privateKey);vardictionary=newDictionary<string,string>();//generatethelicensevarlicense=generator.Generate("EasyLicense",Guid.NewGuid(),DateTime.UtcNow.AddYears(1),dictionary,LicenseType.Standard);txtLicense.Text=license;File.WriteAllText("license.lic",license);

  

3: Usepublickey to validate thelicense

123456789101112131415161718192021privatestaticvoidValidateLicense(){if(!File.Exists("publicKey.xml")){MessageBox.Show("Pleasecreatealicensekeyfirst");return;}varpublicKey=File.ReadAllText(@"publicKey.xml");varvalidator=newLicenseValidator(publicKey,@"license.lic");try{validator.AssertValidLicense();}catch(Exceptionex){Console.WriteLine(ex.Message);}

  

EasyLicense 内部有一个叫LicenseTool的工具,你可以下载源代码,运行,来看看它是怎样的创建Key,创建Licens 和验证License 的。

并且系统还有一个Demo 的项目,可以帮助你。