Windows许可证密钥的所有排列

问题:Windows许可证密钥的所有排列

我需要为笔记本电脑申请Windows 8升级,为此,我需要笔记本电脑下面的Windows 7许可证密钥。

由于Microsoft无限智慧地决定创建会失效的许可证标签,并且我无法清晰地阅读许可证密钥,这意味着我无法使用自动化过程为Windows升级产品注册笔记本电脑。

通过将笔记本电脑与光线倾斜,我可以验证大部分代码,但是其中几个字母是不明确的(再次感谢Microsoft使用易于误读标签中的字符)。

我有以下(混淆的)许可证密钥,

MPP6R-09RXG-2H[8B]MT-[B8]K[HN]M9-V[6G]C8R

其中方括号内的字符是不明确的,因此它是任一8BB8HN6G

制作16种组合。

使用itertools生成此许可证密钥的可能排列是否合适,还是有更好的方法?

感谢贡献者,我得到了正确的钥匙。检查密钥是否有效的一种非常方便的方法是使用Windows 7产品密钥检查器

I need to apply for a Windows 8 upgrade for my laptop, for which I need the Windows 7 license key on the underside of the laptop.

Because Microsoft decided in their infinite wisdom to create license labels that wear off, and I cannot read my license key clearly, it means I can’t register my laptop for the windows upgrade offer using an automated process.

By holding the laptop at an angle to the light I have been able to verify most of the code but several of the letters are ambiguous (thanks again Microsoft for using easy to misread characters in your label).

I have the following (obfuscated) license key,

MPP6R-09RXG-2H[8B]MT-[B8]K[HN]M9-V[6G]C8R

where the characters in square brackets are ambiguous, so it is either 8 or B, B or 8, H or N, 6 or G.

Making 16 combinations.

Is it appropriate to generate the possible permutations of this license key using itertools or is there a better way?

I got the correct key with thanks to the contributors. A very convenient way to check if the key is valid is by using the Windows 7 product key checker.


回答 0

免责声明:是的,我知道这不是Python代码。它只是出现在我脑海里,我只是不得不把它写下来。

最简单的方法是使用Shell扩展:

$ echo MPP6R-09RXG-2H{8,B}MT-{B,8}K{H,N}M9-V{6,G}C8R
MPP6R-09RXG-2H8MT-BKHM9-V6C8R
MPP6R-09RXG-2H8MT-BKHM9-VGC8R
MPP6R-09RXG-2H8MT-BKNM9-V6C8R
MPP6R-09RXG-2H8MT-BKNM9-VGC8R
MPP6R-09RXG-2H8MT-8KHM9-V6C8R
MPP6R-09RXG-2H8MT-8KHM9-VGC8R
MPP6R-09RXG-2H8MT-8KNM9-V6C8R
MPP6R-09RXG-2H8MT-8KNM9-VGC8R
MPP6R-09RXG-2HBMT-BKHM9-V6C8R
MPP6R-09RXG-2HBMT-BKHM9-VGC8R
MPP6R-09RXG-2HBMT-BKNM9-V6C8R
MPP6R-09RXG-2HBMT-BKNM9-VGC8R
MPP6R-09RXG-2HBMT-8KHM9-V6C8R
MPP6R-09RXG-2HBMT-8KHM9-VGC8R
MPP6R-09RXG-2HBMT-8KNM9-V6C8R
MPP6R-09RXG-2HBMT-8KNM9-VGC8R

Disclaimer: Yes, I know that this is not Python code. It just popped into my mind and I simply had to write it down.

The simplest way is the use of shell expansion:

$ echo MPP6R-09RXG-2H{8,B}MT-{B,8}K{H,N}M9-V{6,G}C8R
MPP6R-09RXG-2H8MT-BKHM9-V6C8R
MPP6R-09RXG-2H8MT-BKHM9-VGC8R
MPP6R-09RXG-2H8MT-BKNM9-V6C8R
MPP6R-09RXG-2H8MT-BKNM9-VGC8R
MPP6R-09RXG-2H8MT-8KHM9-V6C8R
MPP6R-09RXG-2H8MT-8KHM9-VGC8R
MPP6R-09RXG-2H8MT-8KNM9-V6C8R
MPP6R-09RXG-2H8MT-8KNM9-VGC8R
MPP6R-09RXG-2HBMT-BKHM9-V6C8R
MPP6R-09RXG-2HBMT-BKHM9-VGC8R
MPP6R-09RXG-2HBMT-BKNM9-V6C8R
MPP6R-09RXG-2HBMT-BKNM9-VGC8R
MPP6R-09RXG-2HBMT-8KHM9-V6C8R
MPP6R-09RXG-2HBMT-8KHM9-VGC8R
MPP6R-09RXG-2HBMT-8KNM9-V6C8R
MPP6R-09RXG-2HBMT-8KNM9-VGC8R

回答 1

from itertools import product
for perm in product('8B', 'B8', 'HN', '6G'):
    print 'MPP6R-09RXG-2H%sMT-%sK%sM9-V%sC8R' % perm
from itertools import product
for perm in product('8B', 'B8', 'HN', '6G'):
    print 'MPP6R-09RXG-2H%sMT-%sK%sM9-V%sC8R' % perm

回答 2

生成组合的另一种方法

>>> ['MPP6R-09RXG-2H%sMT-%sK%sM9-V%sC8R' % (a, b, c, d)
...  for a in '8B' for b in 'B8' for c in 'HN' for d in '6G']
['MPP6R-09RXG-2H8MT-BKHM9-V6C8R',
 'MPP6R-09RXG-2H8MT-BKHM9-VGC8R',
 'MPP6R-09RXG-2H8MT-BKNM9-V6C8R',
 'MPP6R-09RXG-2H8MT-BKNM9-VGC8R',
 'MPP6R-09RXG-2H8MT-8KHM9-V6C8R',
 'MPP6R-09RXG-2H8MT-8KHM9-VGC8R',
 'MPP6R-09RXG-2H8MT-8KNM9-V6C8R',
 'MPP6R-09RXG-2H8MT-8KNM9-VGC8R',
 'MPP6R-09RXG-2HBMT-BKHM9-V6C8R',
 'MPP6R-09RXG-2HBMT-BKHM9-VGC8R',
 'MPP6R-09RXG-2HBMT-BKNM9-V6C8R',
 'MPP6R-09RXG-2HBMT-BKNM9-VGC8R',
 'MPP6R-09RXG-2HBMT-8KHM9-V6C8R',
 'MPP6R-09RXG-2HBMT-8KHM9-VGC8R',
 'MPP6R-09RXG-2HBMT-8KNM9-V6C8R',
 'MPP6R-09RXG-2HBMT-8KNM9-VGC8R']
>>> 

Another way to generate the combinations

>>> ['MPP6R-09RXG-2H%sMT-%sK%sM9-V%sC8R' % (a, b, c, d)
...  for a in '8B' for b in 'B8' for c in 'HN' for d in '6G']
['MPP6R-09RXG-2H8MT-BKHM9-V6C8R',
 'MPP6R-09RXG-2H8MT-BKHM9-VGC8R',
 'MPP6R-09RXG-2H8MT-BKNM9-V6C8R',
 'MPP6R-09RXG-2H8MT-BKNM9-VGC8R',
 'MPP6R-09RXG-2H8MT-8KHM9-V6C8R',
 'MPP6R-09RXG-2H8MT-8KHM9-VGC8R',
 'MPP6R-09RXG-2H8MT-8KNM9-V6C8R',
 'MPP6R-09RXG-2H8MT-8KNM9-VGC8R',
 'MPP6R-09RXG-2HBMT-BKHM9-V6C8R',
 'MPP6R-09RXG-2HBMT-BKHM9-VGC8R',
 'MPP6R-09RXG-2HBMT-BKNM9-V6C8R',
 'MPP6R-09RXG-2HBMT-BKNM9-VGC8R',
 'MPP6R-09RXG-2HBMT-8KHM9-V6C8R',
 'MPP6R-09RXG-2HBMT-8KHM9-VGC8R',
 'MPP6R-09RXG-2HBMT-8KNM9-V6C8R',
 'MPP6R-09RXG-2HBMT-8KNM9-VGC8R']
>>> 

回答 3

如何同时使用itertools和functools?

>>> from operator import mod
>>> from functools import partial
>>> from itertools import product
>>> map(partial(mod, 'MPP6R-09RXG-2H%sMT-%sK%sM9-V%sC8R'), product('8B', 'B8', 'HN', '6G'))
['MPP6R-09RXG-2H8MT-BKHM9-V6C8R', 'MPP6R-09RXG-2H8MT-BKHM9-VGC8R', 'MPP6R-09RXG-2H8MT-BKNM9-V6C8R', 'MPP6R-09RXG-2H8MT-BKNM9-VGC8R', 'MPP6R-09RXG-2H8MT-8KHM9-V6C8R', 'MPP6R-09RXG-2H8MT-8KHM9-VGC8R', 'MPP6R-09RXG-2H8MT-8KNM9-V6C8R', 'MPP6R-09RXG-2H8MT-8KNM9-VGC8R', 'MPP6R-09RXG-2HBMT-BKHM9-V6C8R', 'MPP6R-09RXG-2HBMT-BKHM9-VGC8R', 'MPP6R-09RXG-2HBMT-BKNM9-V6C8R', 'MPP6R-09RXG-2HBMT-BKNM9-VGC8R', 'MPP6R-09RXG-2HBMT-8KHM9-V6C8R', 'MPP6R-09RXG-2HBMT-8KHM9-VGC8R', 'MPP6R-09RXG-2HBMT-8KNM9-V6C8R', 'MPP6R-09RXG-2HBMT-8KNM9-VGC8R']

How about using itertools and functools at the same time?

>>> from operator import mod
>>> from functools import partial
>>> from itertools import product
>>> map(partial(mod, 'MPP6R-09RXG-2H%sMT-%sK%sM9-V%sC8R'), product('8B', 'B8', 'HN', '6G'))
['MPP6R-09RXG-2H8MT-BKHM9-V6C8R', 'MPP6R-09RXG-2H8MT-BKHM9-VGC8R', 'MPP6R-09RXG-2H8MT-BKNM9-V6C8R', 'MPP6R-09RXG-2H8MT-BKNM9-VGC8R', 'MPP6R-09RXG-2H8MT-8KHM9-V6C8R', 'MPP6R-09RXG-2H8MT-8KHM9-VGC8R', 'MPP6R-09RXG-2H8MT-8KNM9-V6C8R', 'MPP6R-09RXG-2H8MT-8KNM9-VGC8R', 'MPP6R-09RXG-2HBMT-BKHM9-V6C8R', 'MPP6R-09RXG-2HBMT-BKHM9-VGC8R', 'MPP6R-09RXG-2HBMT-BKNM9-V6C8R', 'MPP6R-09RXG-2HBMT-BKNM9-VGC8R', 'MPP6R-09RXG-2HBMT-8KHM9-V6C8R', 'MPP6R-09RXG-2HBMT-8KHM9-VGC8R', 'MPP6R-09RXG-2HBMT-8KNM9-V6C8R', 'MPP6R-09RXG-2HBMT-8KNM9-VGC8R']

回答 4

http://www.magicaljellybean.com/keyfinder/

Magical Jelly Bean Keyfinder是一个免费软件实用程序,可从注册表中检索用于安装Windows的产品密钥(cd密钥)。它还具有社区更新的配置文件,该配置文件检索许多其他应用程序的产品密钥。

只需在您想要密钥的安装上运行即可。

http://www.magicaljellybean.com/keyfinder/

The Magical Jelly Bean Keyfinder is a freeware utility that retrieves your Product Key (cd key) used to install windows from your registry. It also has a community-updated configuration file that retrieves product keys for many other applications.

Just run it on the install you want the key for.


回答 5

如果直接在Windows 7中使用Windows Anytime Upgrade选项,则无需知道许可证密钥是什么。

只要激活了操作系统,Windows 8就会覆盖现有的操作系​​统,并将Windows 7中的所有内容放入“ Windows-old”文件夹,您可以删除该文件夹,除非需要文件或其他内容。

Windows升级过程会寻找已激活的Windows操作系统,即使Windows XP也会在安装升级之前激活它。

通过随时升级进行购买时,将通过电子邮件向您发送Windows 8许可证密钥。如果您从商店购买升级,您将只获得许可证密钥和下载URL,或者将密钥插入Windows Anytime Upgrade,它将自行下载并安装。

If you use the Windows Anytime Upgrade option directly from within Windows 7, then you do NOT need to know what the license key is.

As long as the operating system is activated then Windows 8 will just overwrite the existing operating system and place everything from Windows 7 into a “Windows-old” folder which you can delete unless you need a file or something.

The Windows upgrade process looks for an activated Windows operating system, even Windows XP would do as long as it is activated before installing the upgrade.

You will be emailed the Windows 8 license key when purchasing via the Anytime Upgrade. If you buy an upgrade from a store you will just get a license key and a download URL OR you just plug the key into Windows Anytime Upgrade and it will download and install itself.