AsymmetricAlgorithm.ExportEncryptedPkcs8PrivateKey 方法

定義

多載

ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters)

使用位元組型密碼以 PKCS#8 EncryptedPrivateKeyInfo 格式匯出目前金鑰。Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a byte-based password.

ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, PbeParameters)

使用 Char 型密碼以 PKCS#8 EncryptedPrivateKeyInfo 格式匯出目前金鑰。Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a char-based password.

ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters)

使用位元組型密碼以 PKCS#8 EncryptedPrivateKeyInfo 格式匯出目前金鑰。Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a byte-based password.

public:
 virtual cli::array <System::Byte> ^ ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<System::Byte> passwordBytes, System::Security::Cryptography::PbeParameters ^ pbeParameters);
public virtual byte[] ExportEncryptedPkcs8PrivateKey (ReadOnlySpan<byte> passwordBytes, System.Security.Cryptography.PbeParameters pbeParameters);
abstract member ExportEncryptedPkcs8PrivateKey : ReadOnlySpan<byte> * System.Security.Cryptography.PbeParameters -> byte[]
override this.ExportEncryptedPkcs8PrivateKey : ReadOnlySpan<byte> * System.Security.Cryptography.PbeParameters -> byte[]
Public Overridable Function ExportEncryptedPkcs8PrivateKey (passwordBytes As ReadOnlySpan(Of Byte), pbeParameters As PbeParameters) As Byte()

參數

passwordBytes
ReadOnlySpan<Byte>

加密金鑰內容時要用作密碼的位元組。The bytes to use as a password when encrypting the key material.

pbeParameters
PbeParameters

加密金鑰內容時要使用的密碼型加密 (PBE) 參數。The password-based encryption (PBE) parameters to use when encrypting the key material.

傳回

Byte[]

位元組陣列,其中包含此金鑰的 PKCS#8 EncryptedPrivateKeyInfo 表示。A byte array containing the PKCS#8 EncryptedPrivateKeyInfo representation of this key.

例外狀況

無法匯出金鑰。The key could not be exported.

-或--or-

pbeParameters 指出應該使用 TripleDes3KeyPkcs12,這需要 Char 型密碼。pbeParameters indicates that TripleDes3KeyPkcs12 should be used, which requires Char-based passwords.

備註

密碼位元組會直接傳遞至金鑰衍生函式 (KDF 由所表示的演算法所使用的) pbeParametersThe password bytes are passed directly into the Key Derivation Function (KDF) used by the algorithm indicated by pbeParameters. 這可讓您在使用 PBKDF2 (密碼型金鑰衍生函式 2) 處理密碼時,使用 UTF-8 以外的文字編碼來與其他系統相容。This enables compatibility with other systems which use a text encoding other than UTF-8 when processing passwords with PBKDF2 (Password-Based Key Derivation Function 2).

另請參閱

適用於

ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, PbeParameters)

使用 Char 型密碼以 PKCS#8 EncryptedPrivateKeyInfo 格式匯出目前金鑰。Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a char-based password.

public:
 virtual cli::array <System::Byte> ^ ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, System::Security::Cryptography::PbeParameters ^ pbeParameters);
public virtual byte[] ExportEncryptedPkcs8PrivateKey (ReadOnlySpan<char> password, System.Security.Cryptography.PbeParameters pbeParameters);
abstract member ExportEncryptedPkcs8PrivateKey : ReadOnlySpan<char> * System.Security.Cryptography.PbeParameters -> byte[]
override this.ExportEncryptedPkcs8PrivateKey : ReadOnlySpan<char> * System.Security.Cryptography.PbeParameters -> byte[]
Public Overridable Function ExportEncryptedPkcs8PrivateKey (password As ReadOnlySpan(Of Char), pbeParameters As PbeParameters) As Byte()

參數

password
ReadOnlySpan<Char>

加密金鑰產製原料時要使用的密碼。The password to use when encrypting the key material.

pbeParameters
PbeParameters

加密金鑰產製原料時要使用的密碼型加密 (PBE) 參數。The password-based encryption (PBE) parameters to use when encrypting the key material.

傳回

Byte[]

位元組陣列,其中包含此金鑰的 PKCS#8 EncryptedPrivateKeyInfo 表示。A byte array containing the PKCS#8 EncryptedPrivateKeyInfo representation of this key.

例外狀況

無法匯出金鑰。The key could not be exported.

備註

pbeParameters 表示使用 PBKDF2 (密碼型金鑰衍生函式 2) 的演算法時,密碼會透過 utf-8 編碼轉換成位元組。When pbeParameters indicates an algorithm that uses PBKDF2 (Password-Based Key Derivation Function 2), the password is converted to bytes via the UTF-8 encoding.

另請參閱

適用於