What is a 'public key token' and how is it calculated in assembly strong names?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
If you need to generate a public key token based on a full public key, this little static method works:
A public key token is used to identify the organization in a strongly named assembly. This information is added to the assembly metabase. I would assume Richard is correct about the technical way it is stored.
If you want to view the metabase of an assembly, use ILDASM. You can drill down into what is stored in the metabase in addition to seeing the IL.
You can get the PublicKeyToken from the VS Command Line by typing:
From ECMA-335:
As for how the hash is calculated (I assume this may be what you're asking since the public key token is not "calculated"), from the same spec:
You can download the spec here for free: http://www.ecma-international.org/publications/standards/Ecma-335.htm
It is the hash bytes of the key used to sign the assembly.
So rather than listing out hundreds of hex digits for the key, you have something simpler, but still with little risk of collisions.
Regarding your question, "How is it calculated", it's an SHA1 hash.
From dot net blog: