通过许可证密钥启用/禁用代码访问 - 应用程序版本控制
我已经编写了一个 POS 应用程序,现在我想创建它的不同版本。比如基本版、高级版和完整版。因此,如果客户支付更多费用,他们就会在同一应用程序中获得更多功能。我是否可以保留一个标准应用程序,但根据用户输入的许可证密钥启用/禁用我的应用程序中的功能。限制仅当输入特定键时才能执行的部分代码。
大家有什么想法吗...
I have written a POS application, and now i want to create different versions of it. Something like a basic version, a premium version and a Full version. So if a client pays more they get more features in the same application. Is it possible that i could keep one standard application but features in my application get enabled / disabled depending upon what license key user enters. Restrict parts of code that can be executed only if a certain key was entered.
Any ideas guys...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有很多方法可以做到这一点,如果技术人员愿意投入时间,所有这些方法都是可以破解的;-)但是,根据您选择的解决方案,最终需要做更多的工作,所以要现实一点并选择明智地。
对于实际的许可证密钥,我强烈建议您使用标准的公钥-私钥加密方案(例如 rsa)生成它。也就是说,您创建一个许可证密钥文本字符串,其中包含用户名(以便您可以跟踪非法共享的许可证密钥)以及有关哪些代码应处于活动状态的信息。使用私钥对您端的许可证进行加密,并使用包含的公钥分发应用程序。当应用程序启动时,您读取许可证密钥并使用公钥对其进行解密。这将使人们几乎不可能修改或生成假密钥。
现在,对于代码的实际激活,这里有我在生产代码中使用的两个选项:或者简单地在许可证密钥中包含标志,说明代码的哪些部分应该处于活动状态,并使用基本的 if then 语句激活它。或者,根据您的编程语言,您可以从许可证密钥动态加载代码片段,使得这些部分的代码在没有适当的密钥文件的情况下无法使用(我在 java 中使用自定义类加载器执行此操作)....但是,这最后一个解决方案比第一个解决方案需要更多的工作,因此在开始设计解决方案之前请仔细考虑。
There are many ways to do this, all of them breakable if skilled people are willing to put the time into it ;-) However, depending on the solution you choose, it will require progressively more work in your end, so be realistic and choose wisely.
For the actual license key, I highly recommend that you generate it using a standard public-private key encryption scheme such as rsa. That is, you create a license key text string that contains the name of the user (so you can track illegally shared license keys) and information about which code should be active. Encrypt the license on your end using the private key and distribute the app with the public key included. When the app starts, you read the license key and decrypt it using the public key. This will make it virtually impossible for people to modify or generate fake keys.
Now for the actual activation of code, here are two options I have used in production code: either simply include flags in the license key saying which parts of the code should be active and activate it using basic if then statements. Alternatively, depending on your programming language, you can dynamically load pieces of code from the license key making those parts of the code unusable without a proper key file (I did this in java with a custom class loader).... however, this last solution requires much much more work than the first, so think things through before you start designing your solution.