X509Certificate.GetCertHashString Метод

Определение

Возвращает шестнадцатеричную строку, содержащую хэш-значение для сертификата X.509v3.

Перегрузки

GetCertHashString()

Возвращает хэш-значение SHA1 для сертификата X.509v3 в виде шестнадцатеричной строки.

GetCertHashString(HashAlgorithmName)

Возвращает шестнадцатеричную строку, содержащую хэш-значение для сертификата X.509v3, который вычисляется с помощью указанного криптографического хэш-алгоритма.

GetCertHashString()

Возвращает хэш-значение SHA1 для сертификата X.509v3 в виде шестнадцатеричной строки.

public:
 virtual System::String ^ GetCertHashString();
public virtual string GetCertHashString ();
abstract member GetCertHashString : unit -> string
override this.GetCertHashString : unit -> string
Public Overridable Function GetCertHashString () As String

Возвращаемое значение

Представление шестнадцатеричной строки хэш-значения сертификата X.509.

Примеры

В следующем примере метод используется GetCertHashString для получения хэш-значения сертификата X.509, преобразования его в строку и отображения в консоли.

using namespace System;
using namespace System::Security::Cryptography::X509Certificates;
int 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.
   String^ results = cert->GetCertHashString();
   
   // Display the value to the console.
   Console::WriteLine( results );
}

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.
        string results = cert.GetCertHashString();

        // Display the value to the console.
        Console.WriteLine(results);
    }
}
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 String = cert.GetCertHashString()
      
      ' Display the value to the console.
      Console.WriteLine(results)
   End Sub 
End Class

Применяется к

GetCertHashString(HashAlgorithmName)

Возвращает шестнадцатеричную строку, содержащую хэш-значение для сертификата X.509v3, который вычисляется с помощью указанного криптографического хэш-алгоритма.

public:
 virtual System::String ^ GetCertHashString(System::Security::Cryptography::HashAlgorithmName hashAlgorithm);
public virtual string GetCertHashString (System.Security.Cryptography.HashAlgorithmName hashAlgorithm);
abstract member GetCertHashString : System.Security.Cryptography.HashAlgorithmName -> string
override this.GetCertHashString : System.Security.Cryptography.HashAlgorithmName -> string
Public Overridable Function GetCertHashString (hashAlgorithm As HashAlgorithmName) As String

Параметры

hashAlgorithm
HashAlgorithmName

Имя используемого криптографического хэш-алгоритма.

Возвращаемое значение

Представление шестнадцатеричной строки хэш-значения сертификата X.509.

Исключения

hashAlgorithm.Параметр Name имеет значение null или является пустой строкой.

hashAlgorithm — неизвестный алгоритм хэширования.

Применяется к