Click here to Skip to main content
12,078,795 members (52,956 online)
Click here to Skip to main content
Add your own
alternative version


32 bookmarked

Microsoft Product Key Finder

, 31 Jan 2008 CPOL
Rate this:
Please Sign up or sign in to vote.
This program finds Windows XP & Office XP Product Keys.


The Raw Product Key is buried inside the Product Key that is printed on the sticker distributed with each Windows XP CD. It consists of five alphanumeric strings separated by '-' characters, where each string is composed of five characters, as in:


Each character is one of the following 24 letters and digits:

B C D F G H J K M P Q R T V W X Y 2 3 4 6 7 8 9

Very similar to the decimal encoding of the Installation ID, the 25 characters of the Product Key form a base-24 encoding of the binary representation of the Product Key. Decoding the Product Key yields a multi-precision integer of roughly 115 bits, which is stored - again in Little Endian byte order - in an array of 15 bytes. Decoding the above Product Key results in the following byte sequence:

0x6F 0xFA 0x95 0x45 0xFC 0x75 0xB5 0x52
0xBB 0xEF 0xB1 0x17 0xDA 0xCD 0x00

Of these 15 bytes, the least significant four bytes contain the Raw Product Key in Little Endian byte order. The least significant bit is removed by shifting this 32-bit value (0x4595FA6F - remember the Little Endian byte order) to the left by one bit position, resulting in a Raw Product Key of 0x22CAFD37, or 583728439 in decimal notation.

Using the code

Using this code, you can find the product key of your Microsoft products.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32;
namespace MSKeyFinder
    public class KeyDecoder
        public enum Key { XP, Office10, Office11 };
        public static byte[] GetRegistryDigitalProductId(Key key)
            byte[] digitalProductId = null;
            RegistryKey registry = null;
            switch (key)
                // Open the XP subkey readonly.
                case Key.XP:
                    registry =
                          @"SOFTWARE\Microsoft\Windows NT\CurrentVersion",
                // Open the Office 10 subkey readonly.
                case Key.Office10:
                    registry =
                          @"SOFTWARE\Microsoft\Office\10.0\Registration\" + 
                    // TODO: Open the registry key.
                // Open the Office 11 subkey readonly.
                case Key.Office11:
                    // TODO: Open the registry key.
            if (registry != null)
                // TODO: For other products, key name maybe different.
                digitalProductId = registry.GetValue("DigitalProductId")
                  as byte[];
            return digitalProductId;
        public static string DecodeProductKey(byte[] digitalProductId)
            // Offset of first byte of encoded product key in 
            //  'DigitalProductIdxxx" REG_BINARY value. Offset = 34H.
            const int keyStartIndex = 52;
            // Offset of last byte of encoded product key in 
            //  'DigitalProductIdxxx" REG_BINARY value. Offset = 43H.
            const int keyEndIndex = keyStartIndex + 15;
            // Possible alpha-numeric characters in product key.
            char[] digits = new char[]
        'B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'M', 'P', 'Q', 'R', 
        'T', 'V', 'W', 'X', 'Y', '2', '3', '4', '6', '7', '8', '9',
            // Length of decoded product key
            const int decodeLength = 29;
            // Length of decoded product key in byte-form.
            // Each byte represents 2 chars.
            const int decodeStringLength = 15;
            // Array of containing the decoded product key.
            char[] decodedChars = new char[decodeLength];
            // Extract byte 52 to 67 inclusive.
            ArrayList hexPid = new ArrayList();
            for (int i = keyStartIndex; i <= keyEndIndex; i++)
            for (int i = decodeLength - 1; i >= 0; i--)
                // Every sixth char is a separator.
                if ((i + 1) % 6 == 0)
                    decodedChars[i] = '-';
                    // Do the actual decoding.
                    int digitMapIndex = 0;
                    for (int j = decodeStringLength - 1; j >= 0; j--)
                        int byteValue = (digitMapIndex << 8) | (byte)hexPid[j];
                        hexPid[j] = (byte)(byteValue / 24);
                        digitMapIndex = byteValue % 24;
                        decodedChars[i] = digits[digitMapIndex];
            return new string(decodedChars);

Once you realize how the product keys are encoded, a search through the Registry for the values starting with DigitalProductId indicates that many more product keys may be encoded this way.

Further information

To know more about Microsoft product keys, visit:


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

No Biography provided

You may also be interested in...

Comments and Discussions

QuestionHow to decode Office 2016 Pin
Mustafa Furkan YILMAZ23-Nov-15 12:21
memberMustafa Furkan YILMAZ23-Nov-15 12:21 
QuestionGet Office 14 Serial Key Pin
Member 1061512721-Feb-14 5:39
memberMember 1061512721-Feb-14 5:39 
GeneralWindows 8 and Windows 2012 product key Pin
GeorgieWendy2-Nov-13 18:27
memberGeorgieWendy2-Nov-13 18:27 
QuestionWindows 8 Pin
jimiekroth6-Jun-13 17:26
memberjimiekroth6-Jun-13 17:26 
QuestionThis is not working in my winodows 7 Pin
@BangIndia22-May-13 23:27
member@BangIndia22-May-13 23:27 
QuestionAnyone knows how to decode office 2013? Pin
mkdsoft20-Feb-13 6:23
membermkdsoft20-Feb-13 6:23 
AnswerRe: Anyone knows how to decode office 2013? Pin
MasterOfCoders19-Mar-13 12:27
memberMasterOfCoders19-Mar-13 12:27 
SuggestionLittle Tip Pin
Tomasz Karlinski9-Jul-11 4:40
memberTomasz Karlinski9-Jul-11 4:40 
GeneralOffice 14 And Win7 x64 Pin
JonFrost17-May-11 0:19
memberJonFrost17-May-11 0:19 
GeneralRe: Office 14 And Win7 x64 Pin
sigma_ivan18-Feb-14 21:34
membersigma_ivan18-Feb-14 21:34 
SuggestionRe: Office 14 And Win7 x64 Pin
JonFrost8-May-15 6:04
memberJonFrost8-May-15 6:04 
GeneralMy vote of 1 Pin
Peter Ritchie23-Apr-11 6:01
memberPeter Ritchie23-Apr-11 6:01 
GeneralRe: My vote of 1 Pin
reeselmiller28-Jun-11 10:31
memberreeselmiller28-Jun-11 10:31 
GeneralRe: My vote of 1 Pin
Member 950092130-Oct-12 2:21
memberMember 950092130-Oct-12 2:21 
GeneralRe: My vote of 1 Pin
reeselmiller230-Oct-12 10:25
memberreeselmiller230-Oct-12 10:25 
GeneralRecover product key from crashed computer Pin
Steven Noto7-Jun-10 16:44
memberSteven Noto7-Jun-10 16:44 
GeneralMy vote of 1 Pin
Deanno19-Jan-10 7:08
memberDeanno19-Jan-10 7:08 
GeneralProduct Key Encryption Pin
nareshpatel21-Nov-09 19:22
membernareshpatel21-Nov-09 19:22 
General[My vote of 1] This is a copy... Pin
saberint16-Jul-09 17:50
membersaberint16-Jul-09 17:50 
GeneralRe: [My vote of 1] This is a copy... Pin
Member 950092130-Oct-12 2:38
memberMember 950092130-Oct-12 2:38 
GeneralOn Vista Pin
Sanj Gunetileke13-Apr-09 11:25
memberSanj Gunetileke13-Apr-09 11:25 
GeneralNot Working !!! Pin
kwankre3-Jan-09 0:46
memberkwankre3-Jan-09 0:46 
GeneralRe: Not Working !!! Pin
Deanno19-Jan-10 7:06
memberDeanno19-Jan-10 7:06 
GeneralEncoding Product Key Pin
Member 59390314-Mar-08 8:22
memberMember 59390314-Mar-08 8:22 
GeneralRe: Encoding Product Key Pin
Norm .net7-Dec-08 23:15
memberNorm .net7-Dec-08 23:15 
GeneralRe: Encoding Product Key Pin
Adonai23-Feb-09 0:51
memberAdonai23-Feb-09 0:51 
GeneralRe: Encoding Product Key Pin
Norm .net23-Feb-09 1:23
memberNorm .net23-Feb-09 1:23 
GeneralRe: Encoding Product Key Pin
Adonai23-Feb-09 3:06
memberAdonai23-Feb-09 3:06 
I'm sorry. I had to adjust the hardcoded registry key location.
It works fine now!
GeneralRe: Encoding Product Key Pin
moody hesham12-Oct-12 19:56
membermoody hesham12-Oct-12 19:56 
GeneralRe: Encoding Product Key Pin
moody hesham12-Oct-12 19:56
membermoody hesham12-Oct-12 19:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.160212.1 | Last Updated 31 Jan 2008
Article Copyright 2008 by Member 4079427
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid