X509Certificate.GetCertHash 方法

定义

返回对象的 X509Certificate 哈希值。

重载

名称 说明
GetCertHash()

以字节数组的形式返回 X.509v3 证书的哈希值。

GetCertHash(HashAlgorithmName)

返回使用指定的加密哈希算法计算的 X.509v3 证书的哈希值。

GetCertHash()

Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs

以字节数组的形式返回 X.509v3 证书的哈希值。

public:
 virtual cli::array <System::Byte> ^ GetCertHash();
public virtual byte[] GetCertHash();
abstract member GetCertHash : unit -> byte[]
override this.GetCertHash : unit -> byte[]
Public Overridable Function GetCertHash () As Byte()

返回

Byte[]

X.509 证书的哈希值。

示例

以下示例使用 GetCertHash 此方法使用 X.509 证书的哈希值填充字节数组。


using System;
using System.Security.Cryptography.X509Certificates;

public class X509
{

    public static void Main()
    {

        // The path to the certificate.
        string Certificate =  "Certificate.cer";

        // Load the certificate into an X509Certificate object.
        X509Certificate cert = X509Certificate.CreateFromCertFile(Certificate);

        // Get the value.
        byte[] results = cert.GetCertHash();
    }
}
Imports System.Security.Cryptography.X509Certificates




Public Class X509
   
   
   Public Shared Sub Main()
      
      ' The path to the certificate.
      Dim Certificate As String = "Certificate.cer"
      
      ' Load the certificate into an X509Certificate object.
      Dim cert As X509Certificate = X509Certificate.CreateFromCertFile(Certificate)
      
      ' Get the value.
      Dim results As Byte() = cert.GetCertHash()
   End Sub 
End Class

适用于

GetCertHash(HashAlgorithmName)

Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs

返回使用指定的加密哈希算法计算的 X.509v3 证书的哈希值。

public:
 virtual cli::array <System::Byte> ^ GetCertHash(System::Security::Cryptography::HashAlgorithmName hashAlgorithm);
public virtual byte[] GetCertHash(System.Security.Cryptography.HashAlgorithmName hashAlgorithm);
abstract member GetCertHash : System.Security.Cryptography.HashAlgorithmName -> byte[]
override this.GetCertHash : System.Security.Cryptography.HashAlgorithmName -> byte[]
Public Overridable Function GetCertHash (hashAlgorithm As HashAlgorithmName) As Byte()

参数

hashAlgorithm
HashAlgorithmName

要使用的加密哈希算法的名称。

返回

Byte[]

包含 X.509 证书哈希值的字节数组。

例外

hashAlgorithmNamenull 或空字符串。

hashAlgorithm 不是已知的哈希算法。

另请参阅

适用于