Creating a license code scheme

Hello Gents,

I am working on a project that requires me to scan codes in and determine if they are valid. This is similar to a software license key, although I will not have access to the internet for validation.

For this project I may have several hundred thousand codes that get scanned. Originally I wanted to use an SD card to store a master list of valid codes. This will work, but the read/write times are enormous for my controller (Atmel328p).

Instead I wish to create algorithm that checks a security code and determines if it is valid. I believe this is much faster.

It could be as simple as having four 5 digit groups like this: abcde-fghij-klmno-pqrst. Then look for relationships like f + k + p should equal "a". This means 8xxxx-2xxxx-4xxxx-2xxxx is accepted as well as 8xxxx-1xxxx-0xxxx-7xxxx. This just just a simple example. I am looking for something that is more robust, maybe something that checks prime numbers in various positions.

So far I haven't found too many resources on this. Any help would be much appreciated.

You are asking two completely different questions. First, is the code correct and second, is the code valid.

You can add a "check" digit to the number to ensure the number read is correct. To determine if it is "valid" cannot be determined from what you have posted.

there are many schemes to create and validate check digits in numbers. Google will help here. Some schemes will check for transposed digits, others not.

Paul

I am working on a project that requires me to scan codes in and determine if they are valid.

For this to work, the validity check must already be built into the code, or, you have the master list of all possible valid codes.

How do you know if ANY code is valid?

Did you use a binary search?

Worst case is:

1,000,000 codes = log2(1E6)-1 = 18.9 commands.