Get Public Key Hash with SHA256
using System; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; using System.Text; using System.Text.RegularExpressions; using System.Web; public class CryptoUtility { public static string GetPublicKeyHash(X509Certificate certificate) { byte[] rawcert = certificate.GetRawCertData(); X509Certificate x509Cert = new X509Certificate(rawcert); SHA256 sha = new SHA256Managed(); byte[] hashvalue = sha.ComputeHash(x509Cert.GetPublicKey()); return Convert.ToBase64String(hashvalue); } }