Create a key pair
sn -k
creates a public/private key pair and stores it in the indicated file. The content of the file will be binary.
C:\> sn -k PubPriv.snk
…
Key pair written to PubPriv.snk
Extract public key
sn -p
extracts the public key from the previously created file and stores it in a separate file.
C:\> sn -p PubPriv.snk Pub.snk
…
Public key written to Pub.snk
Display public key and public key token
The primary key in Pub.snk
can be displayed with sn -tp
in a non-binary form:
C:\> sn -tp Pub.snk
…
Public key (hash algorithm: sha1):
002400000480000094000000060200000024000052534131000400000100010069314ca642a372
189c7e79ed1981b9564480d4004034c2fd24240e38943c87394405f5fe1874d61d439f302eecf2
5b26c79e0af25fd4ec6787c8fe4f3f771a7ef6ab0535f55611e274005943efb3f1cec85c95b748
93bf8632cd70582056fb00e0e3c38f8a4aab30a5b10c98bb975ff1eeea2dd4c82b66d89ba45e54
5bdecd9a
Public key token is bf748149358f9d4d
Verify strong name in an assembly
C:\> sn -v myAssembly.dll
…
myAssembly.dll does not represent a strongly named assembly
C:\> sn -v anotherAssembly.dll
…
Assembly 'anotherAssembly.dll' is valid
Sometimes, -v
needs to be executed as administrator or in an elevated prompt.