X509Certificate.GetCertHashString 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回包含 X.509v3 证书哈希值的十六进制字符串。
重载
GetCertHashString() |
以十六进制字符串的形式返回 X.509v3 证书的 SHA1 哈希值。 |
GetCertHashString(HashAlgorithmName) |
返回包含使用指定加密哈希算法计算的 X.509v3 证书的哈希值的十六进制字符串。 |
GetCertHashString()
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
以十六进制字符串的形式返回 X.509v3 证书的 SHA1 哈希值。
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)
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
返回包含使用指定加密哈希算法计算的 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
不是已知的哈希算法。