无需用户数据即可生成序列号
这是此问题的后续问题。
接受的答案通常是足够的,但需要用户提供个人信息(例如姓名)来生成密钥。
我想知道是否可以基于公共种子生成不同的密钥,程序能够验证这些密钥是否属于特定产品,但不会使最终用户明显看到此过程。
我的意思是它可能是产品 ID 的哈希加上一些随机字符序列,但这将允许用户猜测潜在的新密钥。应该有某种难以猜测的算法。
This is a followup to this question.
The accepted answer is generally sufficient, but requires user to supply personal information (e.g. name) for generating the key.
I'm wondering if it's possible to generate different keys based on a common seed, in a way that program would be able to validate if those keys belong to particular product, but without making this process obvious to the end user.
I mean it could be a hash of product ID plus some random sequence of characters, but that would allow user to guess potential new keys. There should be some sort of algorithm difficult to guess.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
标准对称/非对称/哈希算法(MDx、SHAx、RSA 等)的问题是它们无法对非常短的字符串(如 20/30 个字符长的产品密钥字符串)进行操作。如果您可以为用户提供约 1000 个字符长的字符串,那么我会选择这些算法。
如果不能,这里有一些 C# 代码,能够构建“几乎完全随机”的短产品密钥,但其中有一个隐藏字节。您可以将任何您想要的内容放入“隐藏字节”中,并且密钥遵循某种不太容易猜测的算法。您可以验证传入的字符串 &使用 TryReadKey() 重读字节,如下所示:
该算法使用 Steganography 原则,当然不是子弹-证明并可以改进,但可能有用。请注意,密钥生成可能需要一些时间,这是正常的。它生成这样的键(注意第一个单词长 6 个字符,其他 5 个字符长):
代码如下:
The problem with standard symmetric/asymetric/hash algorithms (MDx, SHAx, RSA, etc.) is they cannot operate on very short strings like a 20/30 characters-long product key strings. If you can give your users ~1000 characters-long strings, then I would go for these algorithms.
If you can't, here is some C# code that is capable of building an "almost-totally-random" short product key, but with a hidden byte in it. You can put anything you want in that "hidden byte" and the key follows some algorithm that is not so easy to guess. You can validate a passed in string & reread the byte using the TryReadKey() like this:
The algorithm uses Steganography principles, is certainly not bullet-proof and could be improved, but can be useful. Note key generation can take some time, it's normal. It produces keys like this (note the first word is 6 chars long, the other 5 chars long):
Here is the code:
您可以使用由您的密钥生成的数字签名,并将公钥插入到您的程序中。
You can use digital signature, generated by your key, and with public key inserted into your program.