Esempio n. 1
0
        // internal for testing
        internal static ImmutableArray <byte> CalculatePublicKeyToken(ImmutableArray <byte> publicKey)
        {
            var hash = CryptographicHashProvider.ComputeSha1(publicKey);

            // SHA1 hash is always 160 bits:
            Debug.Assert(hash.Length == CryptographicHashProvider.Sha1HashSize);

            // PublicKeyToken is the low 64 bits of the SHA-1 hash of the public key.
            int l      = hash.Length - 1;
            var result = ArrayBuilder <byte> .GetInstance(PublicKeyTokenSize);

            for (int i = 0; i < PublicKeyTokenSize; i++)
            {
                result.Add(hash[l - i]);
            }

            return(result.ToImmutableAndFree());
        }