资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

开源.netlicensetool,EasyLicense!

使用代码:

 

创新互联建站坚持“要么做到,要么别承诺”的工作理念,服务领域包括:网站制作、成都网站设计、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的徐水网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!

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

 

1: Create a public/private Key.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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();
  
            // 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

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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 的。

开源 .net license tool, EasyLicense !

 

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

 

开源 .net license tool, EasyLicense !


当前标题:开源.netlicensetool,EasyLicense!
当前网址:http://cdkjz.cn/article/ppepdi.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220