Extracting private key from a strong name file?

2020-07-18 11:19发布

问题:

As the title states, does anyone know how to extract the private key from an snk file? We want to use the private key from the StrongName for encryption purposes. I read in:
http://msdn.microsoft.com/en-us/library/k5b5tt23(VS.80).aspx that sn -o key.snk will extract both the private/public key if they exist in the file but i tried it and its just a long CSV formatted string with no distinction between what is the private key and what is the public key.

回答1:

In the document you link, next to the -o flag, it says:

If the infile contains a key pair with a private key, the private key is also extracted.

Are you certain there is a private key in the file?

You can run sn -p key.snk to get the public key, and compare that to the output of sn -o key.snk - if they are the same, the key file only has a public key, if not, the difference is the private key.