← 返回命令列表

Linux command

sn 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Create key pair

sn -k [keypair.snk]

Extract public key

sn -p [keypair.snk] [public.snk]

Display token

sn -t [assembly.dll]

Display public key

sn -tp [keypair.snk]

Verify signature

sn -v [assembly.dll]

说明

sn (Strong Name tool) creates and manages cryptographic key pairs used for signing .NET assemblies. Strong naming gives an assembly a unique identity by combining its name, version number, culture information, and a public key, preventing conflicts between assemblies with the same simple name. The tool generates RSA key pairs for signing, extracts public keys for distribution without exposing the private key, and displays public key tokens (a short hash used as a compact identifier). It can also verify that an assembly's strong name signature is valid and re-sign assemblies with a different key pair. Strong naming is part of the .NET Framework and Mono runtime. While still supported, Microsoft now recommends NuGet package signing for most scenarios, and strong naming is primarily used for legacy compatibility and Global Assembly Cache (GAC) registration.

参数

-k _FILE_
Generate key pair.
-p _IN OUT_
Extract public key.
-t _FILE_
Show token.
-tp _FILE_
Show public key.
-v _FILE_
Verify assembly.
-R _FILE KEY_
Re-sign assembly.

FAQ

What is the sn command used for?

sn (Strong Name tool) creates and manages cryptographic key pairs used for signing .NET assemblies. Strong naming gives an assembly a unique identity by combining its name, version number, culture information, and a public key, preventing conflicts between assemblies with the same simple name. The tool generates RSA key pairs for signing, extracts public keys for distribution without exposing the private key, and displays public key tokens (a short hash used as a compact identifier). It can also verify that an assembly's strong name signature is valid and re-sign assemblies with a different key pair. Strong naming is part of the .NET Framework and Mono runtime. While still supported, Microsoft now recommends NuGet package signing for most scenarios, and strong naming is primarily used for legacy compatibility and Global Assembly Cache (GAC) registration.

How do I run a basic sn example?

Run `sn -k [keypair.snk]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -k _FILE_ do in sn?

Generate key pair.