示例#1
0
        public static string HashFromPublicKey(string publicKey)
        {
            // Convert to DER format.
            var der = publicKey.Substring("-----BEGIN PUBLIC KEY-----".Length, publicKey.Length - "-----BEGIN PUBLIC KEY-----".Length - ("-----END PUBLIC KEY-----".Length));
            var data = Convert.FromBase64String(der).ToList().Skip(22);

            data = new SHA1Managed().ComputeHash(data.ToArray());

            var hash = Base32.ToBase32String(data.ToArray()).Substring(0, 16);
            return hash;
        }