net license tool, EasyLicense !

來源:互聯網
上載者:User

標籤:授權   rri   oschina   read   技術   ret   exce   eval   china   

介紹:

 

 

過去我常常像是否有一個協助授權的軟體,它可以非常簡單的建立license,並且非常容易的驗證license。

這是一個非常普通和公用的功能,但是我沒有找到合適的開源軟體,大部分開源軟體都比較複雜,並且有太多我不需要的功能。

 

所以我建立了這個項目,希望可以讓授權的流程變的簡單。

 

使用代碼:

 

Easy License 非常容易使用,為了驗證一個軟體,你需要下面3個步驟。

 

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 = "";            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 內部有一個叫 LicenseTool 的工具,你可以下載原始碼,運行,來看看它是怎樣的建立Key,建立Licens 和驗證License 的。

 

並且系統還有一個Demo 的項目,可以協助你。

 

 

 

 

Git, 請幫忙加個star 吧。

 https://github.com/EasyHelper/EasyLicense

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

  

net license tool, EasyLicense !

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.