CryptographyClient.EncryptAsync Method
Definition
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.
Overloads
EncryptAsync(EncryptionAlgorithm, Byte[], CancellationToken) |
Encrypts the specified plaintext. |
EncryptAsync(EncryptParameters, CancellationToken) |
Encrypts plaintext. |
EncryptAsync(EncryptionAlgorithm, Byte[], CancellationToken)
- Source:
- CryptographyClient.cs
- Source:
- CryptographyClient.cs
Encrypts the specified plaintext.
public virtual System.Threading.Tasks.Task<Azure.Security.KeyVault.Keys.Cryptography.EncryptResult> EncryptAsync (Azure.Security.KeyVault.Keys.Cryptography.EncryptionAlgorithm algorithm, byte[] plaintext, System.Threading.CancellationToken cancellationToken = default);
abstract member EncryptAsync : Azure.Security.KeyVault.Keys.Cryptography.EncryptionAlgorithm * byte[] * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Security.KeyVault.Keys.Cryptography.EncryptResult>
override this.EncryptAsync : Azure.Security.KeyVault.Keys.Cryptography.EncryptionAlgorithm * byte[] * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Security.KeyVault.Keys.Cryptography.EncryptResult>
Public Overridable Function EncryptAsync (algorithm As EncryptionAlgorithm, plaintext As Byte(), Optional cancellationToken As CancellationToken = Nothing) As Task(Of EncryptResult)
Parameters
- algorithm
- EncryptionAlgorithm
The EncryptionAlgorithm to use.
- plaintext
- Byte[]
The data to encrypt.
- cancellationToken
- CancellationToken
A CancellationToken to cancel the operation.
Returns
An EncryptResult containing the encrypted data along with all other information needed to decrypt it. This information should be stored with the encrypted data.
Exceptions
The specified algorithm
does not match the key corresponding to the key identifier.
The local cryptographic provider threw an exception.
The key is invalid for the current operation.
The operation is not supported with the specified key.
The server returned an error. See Message for details returned from the server.
Remarks
Microsoft recommends you not use CBC without first ensuring the integrity of the ciphertext using an HMAC, for example. See https://docs.microsoft.com/dotnet/standard/security/vulnerabilities-cbc-mode for more information.
Applies to
EncryptAsync(EncryptParameters, CancellationToken)
- Source:
- CryptographyClient.cs
- Source:
- CryptographyClient.cs
Encrypts plaintext.
public virtual System.Threading.Tasks.Task<Azure.Security.KeyVault.Keys.Cryptography.EncryptResult> EncryptAsync (Azure.Security.KeyVault.Keys.Cryptography.EncryptParameters encryptParameters, System.Threading.CancellationToken cancellationToken = default);
abstract member EncryptAsync : Azure.Security.KeyVault.Keys.Cryptography.EncryptParameters * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Security.KeyVault.Keys.Cryptography.EncryptResult>
override this.EncryptAsync : Azure.Security.KeyVault.Keys.Cryptography.EncryptParameters * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Security.KeyVault.Keys.Cryptography.EncryptResult>
Public Overridable Function EncryptAsync (encryptParameters As EncryptParameters, Optional cancellationToken As CancellationToken = Nothing) As Task(Of EncryptResult)
Parameters
- encryptParameters
- EncryptParameters
An EncryptParameters containing the data to encrypt and other parameters for algorithm-dependent encryption.
- cancellationToken
- CancellationToken
A CancellationToken to cancel the operation.
Returns
An EncryptResult containing the encrypted data along with all other information needed to decrypt it. This information should be stored with the encrypted data.
Exceptions
The specified algorithm does not match the key corresponding to the key identifier.
encryptParameters
is null.
The local cryptographic provider threw an exception.
The key is invalid for the current operation.
The operation is not supported with the specified key.
The server returned an error. See Message for details returned from the server.
Remarks
Microsoft recommends you not use CBC without first ensuring the integrity of the ciphertext using an HMAC, for example. See https://docs.microsoft.com/dotnet/standard/security/vulnerabilities-cbc-mode for more information.
Applies to
Azure SDK for .NET