What is a public key token and how is it calculated in assembly strong names?

前端 未结 6 2091
走了就别回头了
走了就别回头了 2020-12-24 08:33

What is a \'public key token\' and how is it calculated in assembly strong names?

6条回答
  •  感情败类
    2020-12-24 09:04

    If you need to generate a public key token based on a full public key, this little static method works:

       private static byte[] GetKeyTokenFromFullKey(byte[] fullKey)
        {
            SHA1CryptoServiceProvider csp = new SHA1CryptoServiceProvider();
            byte[] hash = csp.ComputeHash(fullKey);
            byte[] token = new byte[8];
            for (int i = 0; i < 8; i++ )
                token[i] = hash[hash.Length - (i+1)];
    
            return token;
        }
    

提交回复
热议问题