Get Public Key Hash with SHA256 : Hash « Security « C# / C Sharp






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);
    }
}

   
  








Related examples in the same category

1.Verify Hex Hash, Base64 Hash, Byte Hash
2.Generic Hash
3.Get Public Key Hash with HttpClientCertificate
4.Get Public Key Hash for a string
5.Hash As Password
6.Generate Hash
7.Get Hash for password
8.Generates a hash code of the input string
9.Hash Data
10.Hash Password
11.Get SHA256 Hash
12.Create Password Hash