GWK.DecodeProductKeyWin8AndUp Method

public static string DecodeProductKeyWin8AndUp( 
byte[] digitalProductId 
)
This language is not supported or no code example is available.

Parameters

digitalProductId
byte[]

Return Value

string
public static string DecodeProductKeyWin8AndUp(byte[] digitalProductId)
 {
     var key = string.Empty;
     const int keyOffset = 52;
     var isWin8 = (byte)((digitalProductId[66] / 6) & 1);
     digitalProductId[66] = (byte)((digitalProductId[66] & 0xf7) | (isWin8 & 2) * 4);
     const string digits = "BCDFGHJKMPQRTVWXY2346789";
     var last = 0; for (var i = 24; i >= 0; i--)
     {
         var current = 0;
         for (var j = 14; j >= 0; j--)
         {
             current = current * 256;
             current = digitalProductId[j + keyOffset] + current; digitalProductId[j + keyOffset] = (byte)(current / 24); current = current % 24; last = current;
         }
         key = digits[current] + key;
     }
     var keypart1 = key.Substring(1, last);
     var keypart2 = key.Substring(last + 1, key.Length - (last + 1));
     key = keypart1 + "N" + keypart2;
     for (var i = 5; i < key.Length; i += 6)
         key = key.Insert(i, "-");
     return key;
 }
					
This language is not supported or no code example is available.

.NET Framework

Supported in: 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8

.NET Core

Supported in: 5.0+, 6.0+

In this article

Definition