So you want to generate license keys for old Microsoft products?

Daniel Gurney
3 min readOct 18, 2018

--

UPDATE: First off, thank you so much for the continued interest in this article, it’s so cool seeing Medium statistics emails with significant numbers come in on a regular basis even in 2020. I’ve recently launched my own site, and rewrote this article with information on 11-digit CD keys used by Office 97. Click here to read that post!

If you have ever looked into product key algorithms, you have most likely heard of the algorithm Microsoft used in the 90’s in many products, most notably Windows 95 and NT 4. If you haven’t, it’s rather simple: the digit sum of a certain segment of the key must be divisible by seven.

That’s it, right?

Nope. If you only check that the digit sum is divisible by seven, your key might still be rejected by an actual Microsoft setup program. Let’s dig a bit deeper and figure out why. The information contained in this post has been verified with NT 4, but as far as I know all products that use these types of keys behave identically.

CD Keys

Where the hell did I leave my CD key?

Let’s start with the most basic form of key, the 10-digit CD Key. In case you’re not familiar with Microsoft history, they look like this: XXX–XXXXXXX. Let’s break it down and see how it’s validated:

The first segment (also called site) must be three digits long, but it’s not as simple as generating a random number between 000 and 999. The combinations 333, 444, 555, 666, 777, 888, and 999 are invalid, and will cause your key to be rejected by setup.

The second segment is where the infamous algorithm comes in. The digit sum of these numbers must be divisible by 7. However, like I implied in the beginning of this article, it’s not that simple. The last digit is also checked by setup. If it is 0 or ≥ 8, setup will reject your key, even if it passes site number and division checks.

OEM Keys

Oh no, where is my COA?

As the name implies, these keys were typically found on COA labels that you got with a computer, and look like this: XXXXX-OEM-XXXXXXX-XXXXX. Let’s break the validation process down:

The first segment is actually a date. The first three digits represent the Julian date (more commonly called ordinal date outside programming) the key was printed on, and the last two are the printing year.

The date can be anything within 001-366, and the year cannot be lower than 95 or above 03.

This means you can easily figure out when an OEM key was printed by looking at the first segment. For example, a key with 19296 as the first segment was printed on 10th of July 1996.

The second segment is always OEM.

The third segment is the part where the algorithm comes in again. The check itself isn’t different from a CD Key, except that the first digit of the segment must be 0.

The fourth segment is irrelevant, provided it’s the appropriate length.

In conclusion

The algorithm is extremely simple, but unless you take into account some details, your “valid” key might not be valid after all.

Revisions:

  • (19.10.2018) In the CD key section of the article, the lowest CD Key site number was erroneously 001. 000 is also valid.

Sources used: The leaked Windows NT 4 source code.

Disclaimer: This article was written for educational purposes only, and the author does not encourage or endorse obtaining the leaked source code or software piracy of any sort.

--

--