Redigera

Dela via


Pkcs8PrivateKeyInfo.TryEncrypt Method

Definition

Overloads

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

Attempts to produce a PKCS#8 EncryptedPrivateKeyInfo from the property contents of this object after encrypting with the specified byte-based password and encryption parameters, writing the results into a provided buffer.

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

Attempts to produce a PKCS#8 EncryptedPrivateKeyInfo from the property contents of this object after encrypting with the specified character-based password and encryption parameters, writing the result into a provided buffer.

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

Source:
Pkcs8PrivateKeyInfo.cs
Source:
Pkcs8PrivateKeyInfo.cs
Source:
Pkcs8PrivateKeyInfo.cs
Source:
Pkcs8PrivateKeyInfo.cs
Source:
Pkcs8PrivateKeyInfo.cs

Attempts to produce a PKCS#8 EncryptedPrivateKeyInfo from the property contents of this object after encrypting with the specified byte-based password and encryption parameters, writing the results into a provided buffer.

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

Parameters

passwordBytes
ReadOnlySpan<Byte>

The bytes to use as a password when encrypting the key material.

pbeParameters
PbeParameters

The password-based encryption (PBE) parameters to use when encrypting the key material.

destination
Span<Byte>

The byte span to receive the PKCS#8 EncryptedPrivateKeyInfo data.

bytesWritten
Int32

When this method returns, contains a value that indicates the number of bytes written to destination. This parameter is treated as uninitialized.

Returns

true if destination is big enough to receive the output; otherwise, false.

Remarks

The password bytes are passed directly into the Key Derivation Function (KDF) used by the algorithm indicated by pbeParameters. 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).

See also

Applies to

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

Source:
Pkcs8PrivateKeyInfo.cs
Source:
Pkcs8PrivateKeyInfo.cs
Source:
Pkcs8PrivateKeyInfo.cs
Source:
Pkcs8PrivateKeyInfo.cs
Source:
Pkcs8PrivateKeyInfo.cs

Attempts to produce a PKCS#8 EncryptedPrivateKeyInfo from the property contents of this object after encrypting with the specified character-based password and encryption parameters, writing the result into a provided buffer.

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

Parameters

password
ReadOnlySpan<Char>

The password to use when encrypting the key material.

pbeParameters
PbeParameters

The password-based encryption (PBE) parameters to use when encrypting the key material.

destination
Span<Byte>

The byte span to receive the PKCS#8 EncryptedPrivateKeyInfo data.

bytesWritten
Int32

When this method returns, contains a value that indicates the number of bytes written to destination. This parameter is treated as uninitialized.

Returns

true if destination is big enough to receive the output; otherwise, false.

Remarks

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.

See also

Applies to