Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating activation key from serial number

I have devices with unique serial number (string incremetation) ex : AS1002 and AS1003.

I need to figure out an algorithm to produce a unique activation key for each serial number.

What would be the best approach for this ?

Thanks !

(This has to be done offline)

like image 591
David Avatar asked Sep 22 '11 15:09

David


People also ask

How do I get an activation key?

An activation key is a code that is used to register or activate a software application. It is typically composed of letters and numbers, often with hyphens in between activation key segments.

What is a serial key generator?

A key generator (keygen) is a cryptographic tool used to generate product keys, which are unique alpha-numeric sequences that tell an installer program that the user that initiated the install owns a license of the software.

Is serial number and product key the same?

A product key should not be referred to as a serial number to help prevent confusion with a computer or hardware products serial number. Above is an example of the Microsoft Windows XP Home Edition product key. Usually, it is on the side or bottom of an OEM desktop computer.

How do I create a serial number for a product?

Create and manage products with serial numbers in Holded Access the product you have created. Click on Manage serial numbers. In the pop-up window, hover over the NS field to edit the serial number generated by default, or click Add serial number to include additional serial numbers. Select Confirm to save the changes.


2 Answers

You have two things to consider here:
- Whatever key you generate must be able to be entered easily, so this eliminates some weird hash which may produce characters which will be cumbersome to type, although this can be overcome, it’s something you should consider.
- The operation as you stated must be done online

Firstly, there will be no way to say with absolute certainty that someone will not be able to decipher your key generation routine, no matter how much you attempt to obfuscate. Just do a search engine query for “Crack for Xyz software”.

This has been a long battle that will never end, hence the move to deliver software as services, i.e. online where the producer has more control over their content and can explicitly authorize and authenticate a user. In your case you want to do this offline. So in your scenario someone will attach your device to some system, and the accompanying software that you intend to write this routine on will make a check against the serial number of the device v/s user input.

Based on @sll’s answer, given the offline nature of your request. Your best, unfortunately would be to generate a set of random codes, and validate them when user’s call in.

Here is a method borrowed from another SO answer, I've added digits as well

private readonly Random _rng = new Random();
private const string _chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"; //Added 1-9

private string RandomString(int size)
{
    char[] buffer = new char[size];

    for (int i = 0; i < size; i++)
    {
        buffer[i] = _chars[_rng.Next(_chars.Length)];
    }
    return new string(buffer);
}

So, generating one for each of your devices and storing them somewhere might be your only option because of the offline considerations.

This routine will produce strings like this when set to create a 10 digit string, which is reasonably random.

3477KXFBDQ
ROT6GRA39O
40HTLJPFCL
5M2F44M5CH
CAVAO780NR
8XBQ44WNUA
IA02WEWOCM
EG11L4OGFO
LP2UOGKKLA
H0JB0BA4NJ
KT8AN18KFA

like image 65
Ta01 Avatar answered Sep 26 '22 03:09

Ta01


By far the most secure way to do it is to have a centralized database of (serial number, activation key) pairs and have the user activate over the internet so you can check the key locally (on the server).

In this implementation, the activation key can be completely random since it doesn't need to depend on the serial number.

like image 30
Blindy Avatar answered Sep 26 '22 03:09

Blindy