How to generate CD Keys

Where can I find an algorithm to generate and include CD Keys in my applications?

In C# or C++

CD Keys like Microsoft uses for it's applications (ex. XX35-KJ32-PLKF-K43J)
Who is Participating?

Improve company productivity with a Business Account.Sign Up

AndyAinscowConnect With a Mentor Freelance programmer / ConsultantCommented:
Whatever you wish.

This is one possibility:

StephanLead Software EngineerCommented:
Take a look at this:

This will give you an insight how you can generate your keys.
AndyAinscowFreelance programmer / ConsultantCommented:
I don't know if there is a 'standard'.  In fact if one thinks about it then a standard way could be abused.

You will need code to create a key AND code to check the key the user enters is valid.

I suggest you need to think about what information you require in the key.  What format the key has.  What sort of extra padding you want in the key to give a constant length.  Possibly one or two chars for a checksum type of validation.  Finally an encryption routine to then hide things.

I've done things like having an expiry date as 5 digits, the 1st in char 4, 2nd in char 11....
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

evo_xAuthor Commented:
I need to include the product id, version number and reseller id
any method would be good as an example.
evo_xAuthor Commented:
AndyAinscow: That is what I am looking for but that is a commercial library, I want to implement my own instead of paying $250
AndyAinscowFreelance programmer / ConsultantCommented:
What I did was sit down with a piece of paper and list what I required.  Worked out how many digits I needed, then jumbled the digits around.  A couple of hours and everything was coded.
evo_xAuthor Commented:
And what encryption method should I use? which is free of course for commercial use.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.