AsymmetricAlgorithm.TryExportEncryptedPkcs8PrivateKeyPem 方法

定義

多載

TryExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Byte>, PbeParameters, Span<Char>, Int32)

嘗試使用以位元組為基礎的密碼 PEM 編碼,以 PKCS#8 EncryptedPrivateKeyInfo 格式匯出目前的金鑰。

TryExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Char>, PbeParameters, Span<Char>, Int32)

使用字元型密碼 PEM 編碼,以 PKCS#8 EncryptedPrivateKeyInfo 格式匯出目前的金鑰。

TryExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Byte>, PbeParameters, Span<Char>, Int32)

來源:
AsymmetricAlgorithm.cs
來源:
AsymmetricAlgorithm.cs

嘗試使用以位元組為基礎的密碼 PEM 編碼,以 PKCS#8 EncryptedPrivateKeyInfo 格式匯出目前的金鑰。

public:
 bool TryExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<System::Byte> passwordBytes, System::Security::Cryptography::PbeParameters ^ pbeParameters, Span<char> destination, [Runtime::InteropServices::Out] int % charsWritten);
public bool TryExportEncryptedPkcs8PrivateKeyPem (ReadOnlySpan<byte> passwordBytes, System.Security.Cryptography.PbeParameters pbeParameters, Span<char> destination, out int charsWritten);
member this.TryExportEncryptedPkcs8PrivateKeyPem : ReadOnlySpan<byte> * System.Security.Cryptography.PbeParameters * Span<char> * int -> bool
Public Function TryExportEncryptedPkcs8PrivateKeyPem (passwordBytes As ReadOnlySpan(Of Byte), pbeParameters As PbeParameters, destination As Span(Of Char), ByRef charsWritten As Integer) As Boolean

參數

passwordBytes
ReadOnlySpan<Byte>

加密金鑰內容時要用作密碼的位元組。

pbeParameters
PbeParameters

加密金鑰產製原料時要使用的密碼型加密 (PBE) 參數。

destination
Span<Char>

要接收 PEM 編碼 PKCS#8 EncryptedPrivateKeyInfo 資料的字元範圍。

charsWritten
Int32

當這個方法傳回時,會包含值,指出寫入 的 destination 字元數。 這個參數會被視為未初始化。

傳回

destination 夠大可接收輸出,則為 true;否則為 false

例外狀況

無法匯出金鑰。

備註

PEM 編碼的 PKCS#8 EncryptedPrivateKeyInfo 會以 開頭 -----BEGIN ENCRYPTED PRIVATE KEY----- 和結尾 -----END ENCRYPTED PRIVATE KEY----- ,且 PEM 界限之間金鑰的 base64 編碼 DER 內容。

PEM 會根據 IETF RFC 7468「strict」 編碼規則進行編碼。

適用於

TryExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Char>, PbeParameters, Span<Char>, Int32)

來源:
AsymmetricAlgorithm.cs
來源:
AsymmetricAlgorithm.cs
來源:
AsymmetricAlgorithm.cs

使用字元型密碼 PEM 編碼,以 PKCS#8 EncryptedPrivateKeyInfo 格式匯出目前的金鑰。

public:
 bool TryExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<char> password, System::Security::Cryptography::PbeParameters ^ pbeParameters, Span<char> destination, [Runtime::InteropServices::Out] int % charsWritten);
public bool TryExportEncryptedPkcs8PrivateKeyPem (ReadOnlySpan<char> password, System.Security.Cryptography.PbeParameters pbeParameters, Span<char> destination, out int charsWritten);
member this.TryExportEncryptedPkcs8PrivateKeyPem : ReadOnlySpan<char> * System.Security.Cryptography.PbeParameters * Span<char> * int -> bool
Public Function TryExportEncryptedPkcs8PrivateKeyPem (password As ReadOnlySpan(Of Char), pbeParameters As PbeParameters, destination As Span(Of Char), ByRef charsWritten As Integer) As Boolean

參數

password
ReadOnlySpan<Char>

加密金鑰產製原料時要使用的密碼。

pbeParameters
PbeParameters

加密金鑰產製原料時要使用的密碼型加密 (PBE) 參數。

destination
Span<Char>

要接收 PEM 編碼 PKCS#8 EncryptedPrivateKeyInfo 資料的字元範圍。

charsWritten
Int32

當這個方法傳回時,會包含值,指出寫入 的 destination 字元數。 這個參數會被視為未初始化。

傳回

destination 夠大可接收輸出,則為 true;否則為 false

例外狀況

無法匯出金鑰。

備註

pbeParameters 指出使用 PBKDF2 (密碼型金鑰衍生函數 2) 的演算法時,密碼會透過 UTF-8 編碼轉換成位元組。

          A PEM-encoded PKCS#8 EncryptedPrivateKeyInfo will begin with
        `-----BEGIN ENCRYPTED PRIVATE KEY-----` and end with
        `-----END ENCRYPTED PRIVATE KEY-----`, with the base64 encoded DER
          contents of the key between the PEM boundaries.

          The PEM is encoded according to the IETF RFC 7468 "strict"
          encoding rules.

適用於