Open source. NET License tool, Easylicense!

Source: Internet
Author: User

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"))             {                 var result = MessageBox.Show ("The key is existed, override it?",  "Warning", Messageboxbutton.yesno);                 if  (Result = = messageboxresult.no)                 {                      return;                }             }              var privatekey =  "";   &Nbsp;         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:use private key to create a license

1234567891011121314151617 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 license             var license = 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 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);            }         

  

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.

650) this.width=650; "Src=" Http://images2015.cnblogs.com/blog/67224/201707/67224-20170704071345050-86729532.png " Style= "margin:0px;padding:0px;border:0px;"/>

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

650) this.width=650; "Src=" Http://images2015.cnblogs.com/blog/67224/201707/67224-20170704071429034-7324426.png " Style= "margin:0px;padding:0px;border:0px;"/>


Open source. 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.