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)

使用基于字符的密码以 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[]

参数

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 指示应使用需要基于 Char 密码的 TripleDes3KeyPkcs12pbeParameters indicates that TripleDes3KeyPkcs12 should be used, which requires Char-based passwords.

注解

密码字节直接传递到由指示pbeParameters的算法使用的密钥派生函数(KDF)。The 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)

使用基于字符的密码以 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[]

参数

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.

另请参阅

适用于