How to create a "registration key" for my application

Posted on 2006-05-05
Last Modified: 2008-01-16

I am trying to create simple a registration key (CD KEY) system for my applications,
I want a the ability to create a private key and lots and lots of public keys from the private key

For example
I would have a dialog box where my users could enter the public key I have generated for them that would get compared to the private key that is embedded in side of my application, if the public key is valid then the program will unlock its self.

I am looking for a tutorial in C/C++ or MFC on creating private/public keys and validating them.
A link will do,

I know close to nothing about encryption
I’m experienced in C\C++\MFC

Thank you for your time and effort
Question by:funvill
    LVL 25

    Expert Comment

    Well, the RSA algorithm is not highly difficult to implement yourself...

    Once you have implemented such an algorithm though, when the user provides the public key, to ensure that it is suited to the embedded private key, you simply encrypt something with the public key, decrypt the ciphertext with the private key, and then return the decrypted result to the original data... if they match, then it's a valid pair.

    Wikipedia has info regarding the RSA algorithm (how it works exactly), check it out !
    LVL 2

    Author Comment

    Thanks for your replay

    Will I be able to generate lots of different public keys with a signle private key?
    Do you have a C/C++/MFC tutorial online about RSA that I could look over?

    Is there a public/free for commercial use class or library I could use to create and validate RSA keys?
    LVL 25

    Accepted Solution

    > Will I be able to generate lots of different public keys with a signle private key?

    No; there is a single mapping from public to private — not several.

    But, if you're just thinking of a way to create registration keys for some software of yours, then a better technique would probably be to use AES ("Rijndael"). This is a symmetric cipher algorithm - meaning that there's just a single key.

    The key will be embedded into the software (hard-coded). When the user provides his or her name and password (for example), your systems will use the same key embedded into the software, to encrypt their name and password - the resulting ciphertext will then be used to produce a registration key.

    Then, to register the software, the user types his/her name, password, and registration key into the software. The software performs the encryption etc on the name and password, and compares the result to the registration key.

    If they match, then it's valid - and the software is now registered...

    Here's a C++ implementation of the AES algorithm:
    LVL 2

    Author Comment

    Workes great

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
    Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
    The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
    The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now