Open-source. net license tool, EasyLicense !, Licenseeasylicense

Source: Internet
Author: User

Open-source. net license tool, EasyLicense !, Licenseeasylicense
Introduction:

 

 

In the past, I often used to check whether there is a software that helps with authorization. It can easily create a license and easily verify the license.

This is a very common and public function, but I have not found a suitable open-source software. Most open-source software is complicated and has many features I don't need.

 

So I created this project, hoping to simplify the authorization process.

 

Code:

 

Easy License is very Easy to use. To verify a software, you need to take the following three steps.

 

1: CreatePublic/privateKey.

 

if (File.Exists("privateKey.xml") || File.Exists("publicKey.xml")){var result = MessageBox.Show("The key is existed, override it?", "Warning", MessageBoxButton.YesNo);if (result == MessageBoxResult.No){return;}}var privateKey = "";var publicKey = "";LicenseGenerator.GenerateLicenseKey(out privateKey, out publicKey);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

 

if (!File.Exists("privateKey.xml")){MessageBox.Show("Please create a license key first");return;} var privateKey = File.ReadAllText(@"privateKey.xml");var generator = new LicenseGenerator(privateKey); var dictionary = new Dictionary<string, string>(); // generate the licensevar license = generator.Generate("EasyLicense", Guid.NewGuid(), DateTime.UtcNow.AddYears(1), dictionary,LicenseType.Standard);txtLicense.Text = license;File.WriteAllText("license.lic", license);

  

 

3: UsePublicKey to validate the license

 

private static void ValidateLicense(){if (!File.Exists("publicKey.xml")){MessageBox.Show("Please create a license key first");return;}var publicKey = File.ReadAllText(@"publicKey.xml"); var validator = new LicenseValidator(publicKey, @"license.lic"); try{validator.AssertValidLicense();}catch (Exception ex){Console.WriteLine(ex.Message);}

  

 

There is an internal EasyLicense namedLicenseToolTool, you can download the source code, run, to see how it creates a Key, create Licens and verify License.

 

The system also has a Demo project to help you.

 

 

 

 

Git. Please add a star.

Https://github.com/EasyHelper/EasyLicense

Http://git.oschina.net/EasyHelper/EasyLicense

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.