Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Attempts to encrypt the input data with a specified padding mode into a provided buffer.
public:
virtual bool TryEncrypt(ReadOnlySpan<System::Byte> data, Span<System::Byte> destination, System::Security::Cryptography::RSAEncryptionPadding ^ padding, [Runtime::InteropServices::Out] int % bytesWritten);
public virtual bool TryEncrypt(ReadOnlySpan<byte> data, Span<byte> destination, System.Security.Cryptography.RSAEncryptionPadding padding, out int bytesWritten);
abstract member TryEncrypt : ReadOnlySpan<byte> * Span<byte> * System.Security.Cryptography.RSAEncryptionPadding * int -> bool
override this.TryEncrypt : ReadOnlySpan<byte> * Span<byte> * System.Security.Cryptography.RSAEncryptionPadding * int -> bool
Public Overridable Function TryEncrypt (data As ReadOnlySpan(Of Byte), destination As Span(Of Byte), padding As RSAEncryptionPadding, ByRef bytesWritten As Integer) As Boolean
The data to encrypt.
The padding mode.
When this method returns, the total number of bytes written into destination
. This parameter is treated as uninitialized.
true
if destination
is long enough to receive the encrypted data; otherwise, false
.
padding
is null
.
padding
is unknown, or not supported by this implementation.
-or-
The length of data
is too long for the combination of KeySize and the selected padding.
-or-
The encryption operation failed.
The default implementation of this method calls Encrypt(Byte[], RSAEncryptionPadding) and copies the result to destination
.
Derived types should override this method to avoid the intermediate array creation.
The RSA encryption algorithm will always produce an output equal to the number of bytes required for KeySize bits.
Product | Versions |
---|---|
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in