Hi, I have a client who is asking for some generated product keys. This is not an issue and have created 25,000 unique keys for him so far. Now though, he is asking for more and I'm not sure how many more I can uniquely create. My keys are in the format of: XXXX-XXXX-XXXX-XXXX-XXXX Code (markup): With each 4 character section containing A-Z0-9 (only uppercase). Is there an equation I can do to work out how many codes I can create with out having to keep inserting into a DB table until it starts throwing errors?
NickW2 is theoretically right, but from a practical standpoint, you're going to want to avoid ones like: YOUR-MOMS-ABIG-DUMB-SLUT Or maybe not.
Putting the "YOUR-MOMS-ABIG-DUMB-SLUT" key aside, the problem with what you're suggesting, is that you would need to create keys incrementally or with some logic if you don't want to check to see if the key exists. This isn't a good way of doing it unless you can develop a very complex and non-reversible key generator. The last thing you want is keys that can be guessed. Key collisions and incremented keys cause a lot of problems for licensing when someone figures out how to create a valid key for a product.
With that many possible combinations, the chance of randomly generating the same key twice even if you're doing millions of keys is infinitesimal. You'd have more chance of winning the lottery several times in a row then producing the same key twice. Completely random keys is the best way of doing it. I wouldn't bother checking for duplicates until you're in the range of generating trillions of keys (literally). There's more possible keys there than the number of grains of sand on Earth multiplied by 100 billion.
But if you don't check a database for duplicate keys and actually run fraud checks on your licenses then you run the chance of having flawed system. And if you system is flawed then the keys are only a scare tactic for consumers. Processing a check on a code takes only a few lines of code and would not be a bother at all for anyone that knows programming to implement I would suggest checking and having a database if you wish to go to the trouble of having a key at all.
No, I agree, checking the keys in a database wouldn't be an issue at all given the (relatively small) number of keys you're likely to be generating. There is literally no point though. And I'm of course talking purely about the generation of keys, not checking the keys are authorised and only being used once etc. There'd be no point generating product keys if you weren't putting them in a database to verify the legitimacy of a customer's key.
A-Z = 26 character 0-9 = 10 characters Key lenght = 20 characters You can uniquely create 36^20 keys which is good enough to serve your client till his death Not sure what you meant by that.