NET License tool, Easylicense!

Source: Internet
Author: User

Introduced:

In the past I used to like whether there was a software to help the authorization, it can be very simple to create license, and very easy to verify the license.

This is a very common and public function, but I did not find the right open source software, most of the open source software is more complex, and there are too many features I do not need.

So I created this project and I wanted to make the authorization process simple.

Using code:

Easy License is very simple to use, in order to verify a software, you need the following 3 steps.

1:create a public/private Key.

1234567891011121314151617 if(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:use Private key to create a license

1234567891011121314151617 if(!File.Exists("privateKey.xml"))            {                MessageBox.Show("Please create a license key first");                return;            }             varprivateKey = File.ReadAllText(@"privateKey.xml");            vargenerator = newLicenseGenerator(privateKey);              vardictionary = newDictionary<stringstring>();             // generate the license            varlicense = generator.Generate("EasyLicense", Guid.NewGuid(), DateTime.UtcNow.AddYears(1), dictionary,                LicenseType.Standard);                        txtLicense.Text = license;            File.WriteAllText("license.lic", license);

  

3:use Public key to validate the license

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

  

Easylicense inside there is a tool called Licensetool , you can download the source code, run, see how it is created key, create Licens and verify license.

And the system also has a demo project that can help you.

Git, please help to add a star bar.

Https://github.com/EasyHelper/EasyLicense

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

NET License tool, Easylicense!

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.