AsymmetricAlgorithm.TryExportEncryptedPkcs8PrivateKeyPem 方法
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
TryExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Byte>, PbeParameters, Span<Char>, Int32) |
尝试使用基于字节的密码(PEM 编码)导出 PKCS#8 EncryptedPrivateKeyInfo 格式的当前密钥。 |
TryExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Char>, PbeParameters, Span<Char>, Int32) |
使用基于字符的密码(PEM 编码)导出 PKCS#8 EncryptedPrivateKeyInfo 格式的当前密钥。 |
- Source:
- AsymmetricAlgorithm.cs
- Source:
- 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) 参数。
- 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“严格”编码规则进行编码。
适用于
.NET 10 和其他版本
产品 | 版本 |
---|---|
.NET | 8, 9, 10 |
- Source:
- AsymmetricAlgorithm.cs
- Source:
- AsymmetricAlgorithm.cs
- Source:
- 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) 参数。
- 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.
适用于
.NET 10 和其他版本
产品 | 版本 |
---|---|
.NET | 7, 8, 9, 10 |