对于那些不害羞的人,可以做一些编码。
我在10年前发现了一种算法,并在C#中实现了该算法(请参见下文)
如果您只想在Windows上运行
我自由地将其转换为powershell脚本:
$dpid = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name "DigitalProductId"
# Get the range we are interested in
$id = $dpid.DigitalProductId[52..(52+14)]
# Character table
$chars = "BCDFGHJKMPQRTVWXY2346789"
# Variable for the final product key
$pkey = ""
# Calculate the product key
for ($i=0; $i -le 24; $i++) {
$c = 0
for($j=14; $j -ge 0; $j--) {
$c = ($c -shl 8) -bxor $id[$j]
$id[$j] = [Math]::Floor($c / 24) -band 255
$c = $c % 24
}
$pkey = $chars[$c] + $pkey
}
# Insert some dashes
for($i = 4; $i -gt 0; $i--) {
$pkey = $pkey.Insert($i * 5, "-")
}
$pkey
运行此命令,您将获得产品密钥。(因此,最终没有为您编码)
原始帖子
这就是我挖掘并注释的实际C#代码。
public static string ConvertDigitalProductID(string regPath, string searchKey = "DigitalProductID") {
// Open the sub key i.E.: "Software\Microsoft\Windows NT\CurrentVersion"
var regkey = Registry.LocalMachine.OpenSubKey(regPath, false);
// Retreive the value of "DigitalProductId"
var dpid = (byte[])regkey.GetValue(searchKey);
// Prepare an array for the relevant parts
var idpart = new byte[15];
// Copy the relevant parts of the array
Array.Copy(dpid, 52, idpart, 0, 15);
// Prepare the chars that will make up the key
var charStore = "BCDFGHJKMPQRTVWXY2346789";
// Prepare a string for the result
string productkey = "";
// We need 24 iterations (one for each character)
for(int i = 0; i < 25; i++) {
int c = 0;
// Go through each of the 15 bytes of our dpid
for(int j = 14; j >= 0; j--) {
// Shift the current byte to the left and xor in the next byte
c = (c << 8) ^ idpart[j];
// Leave the result of the division in the current position
idpart[j] = (byte)(c / 24);
// Take the rest of the division forward to the next round
c %= 24;
}
// After each round, add a character from the charStore to our key
productkey = charStore[c] + productkey;
}
// Insert the dashes
for(int i = 4; i > 0; i--) {
productkey = productkey.Insert(i * 5, "-");
}
return productkey;
}
您必须将其Software\Microsoft\Windows NT\CurrentVersion
作为密钥传递,然后才能在其中找到DigitalProductId
当时MS Office产品使用相同的算法,因此通过为函数提供相关的注册表项,它也可以计算这些产品密钥。
当然,您可以重构该函数,使其将字节数组作为输入。
至于今天。我刚刚在Windows 10机器上对其进行了测试,但仍然可以使用。