Pkcs8PrivateKeyInfo.TryEncrypt 方法

定义

重载

TryEncrypt(ReadOnlySpan<Byte>, PbeParameters, Span<Byte>, Int32)

在使用指定的基于字节的密码和加密参数进行加密后,尝试根据此对象的属性内容生成 PKCS#8 EncryptedPrivateKeyInfo,并将结果写入到提供的缓冲区中。

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

在使用指定的基于字符的密码和加密参数进行加密后,尝试根据此对象的属性内容生成 PKCS#8 EncryptedPrivateKeyInfo,并将结果写入到提供的缓冲区中。

TryEncrypt(ReadOnlySpan<Byte>, PbeParameters, Span<Byte>, Int32)

在使用指定的基于字节的密码和加密参数进行加密后,尝试根据此对象的属性内容生成 PKCS#8 EncryptedPrivateKeyInfo,并将结果写入到提供的缓冲区中。

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

参数

passwordBytes
ReadOnlySpan<Byte>

加密密钥材料时用作密码的字节。

pbeParameters
PbeParameters

加密密钥材料时使用的基于密码加密 (PBE) 参数。

destination
Span<Byte>

接收 PKCS#8 EncryptedPrivateKeyInfo 数据的字节范围。

bytesWritten
Int32

此方法返回时,包含一个指示写入 destination 的字节数的值。 该参数未经初始化即被处理。

返回

Boolean

如果 destination 具有足够的大小以接收输出,则为 true;否则为 false

注解

密码字节直接传递到密钥派生函数中, (KDF) 由算法指示 pbeParameters。 这可实现与其他使用 UTF-8 以外的文本编码(使用 PBKDF2 处理密码时) (基于密码的密钥派生函数 2) 的兼容性。

另请参阅

适用于

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

在使用指定的基于字符的密码和加密参数进行加密后,尝试根据此对象的属性内容生成 PKCS#8 EncryptedPrivateKeyInfo,并将结果写入到提供的缓冲区中。

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

参数

password
ReadOnlySpan<Char>

加密密钥材料时使用的密码。

pbeParameters
PbeParameters

加密密钥材料时使用的基于密码加密 (PBE) 参数。

destination
Span<Byte>

接收 PKCS#8 EncryptedPrivateKeyInfo 数据的字节范围。

bytesWritten
Int32

此方法返回时,包含一个指示写入 destination 的字节数的值。 该参数未经初始化即被处理。

返回

Boolean

如果 destination 具有足够的大小以接收输出,则为 true;否则为 false

注解

pbeParameters 指示使用 PBKDF2 (基于密码的密钥派生函数 2) 的算法时,密码将通过 UTF-8 编码转换为字节。

另请参阅

适用于