对于C#服务器控制生成/验证许可密钥 [英] Generating / Validating License Key for C# Server Control

查看:758
本文介绍了对于C#服务器控制生成/验证许可密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现一对夫妇的帖子提示的专有解决方案,做我在寻找什么的。我希望有人有他们可以通过沿教程..反正 - 这里就是我需要的:

I've found a couple of posts suggesting proprietary solutions that do what I'm looking for. I'm hoping someone has a tutorial they can pass along.. Anyways - here's what I need:

我有一个专为Sitefinity的服务器控件。它编译成一个DLL。当有人购买了控制,我想生成许可证文件(.txt /名为.lic),其中包含一个关键具体到他们的站点URL /主机名。许可文件应支持多个URL /主机名 - 如果他们需要工作,他们的开发和生产基地。

I have a server control that is built for Sitefinity. It's compiled into a DLL. When someone purchases the control, I'd like to generate a license file (.txt / .lic) that contains a key specific to their site URL / hostname. The license file should support multiple URLs/hostnames - in case they need it to work on their dev and production sites.

当有人试图加载控件,无需适当的许可文件 - 它只会吐出一个不许可的消息。

When someone tries to load up the control without having the proper license file - it will just spit out a "Not licensed" message.

有什么想法?我看微软对服务器控制许可页面 - 这是方式在我的头上。这也许可的机器。我想用URL /主机名的许可证。

Any thoughts? I've looked at Microsoft's page on Server Control Licensing - and it was way over my head. It also licensed by Machine. I'd like to license by URL/hostname.

推荐答案

我不能为你提供基于现有框架的答案。在这里,我的解决方案

I cannot provide you an answer based on an existing framework. Here my solution

  1. 基本思路:使用签名就像在电子邮件。签名的数据是授权的URL。
  2. 创建一个公共/私有密钥使用正则非对称加密技术(提供足够的教程)对。
  3. 嵌入到您编译的DLL公钥。
  4. 当控件呈现,加载许可文件,使用嵌入式公钥验证其签名,验证当前访问的URL对许可文件中找到所提供的网址(这是由签名保护)。
  5. 在成功:让它流
  6. 在失败:加入你的留言输出
  7. (出于性能:在缓存应用程序数据存储的授权令牌)
  8. (为了保护mechansim的:适用于装配一个code混淆器)

另外,你需要一个工具使用私有密钥(这是不是分布式组件的一部分,但只是这个工具来创建许可证。

Additional you need a tool to create the licenses using the private key (which is not part of the distributed assembly but just this tool.

更新:作为我看你最关心的是创造的许可证密钥:

Update: As I see you biggest concern is the creation of the license key:

  1. 创建一个Windows窗体应用程序
  2. 创建一个文本框,允许多行
  3. 在每行可以有一个网址接受。
  4. 在采取一切行文字,使用的StreamWriter(基于CryptoStream的基础上的FileStream)。
  5. 的CryptoStream的使用这是之前创建的私有密钥。
  6. 通过FileStream是开放的,你要分发的许可文件。

希望帮助!

这篇关于对于C#服务器控制生成/验证许可密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆