CryptographyClient.EncryptAsync Method

Definition

Overloads

EncryptAsync(EncryptParameters, CancellationToken)

Encrypts plaintext.

EncryptAsync(EncryptionAlgorithm, Byte[], CancellationToken)

Encrypts the specified plaintext.

EncryptAsync(EncryptParameters, CancellationToken)

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
System.Threading.CancellationToken

A System.Threading.CancellationToken to cancel the operation.

Returns

System.Threading.Tasks.Task<EncryptResult>

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

System.ArgumentException

The specified algorithm does not match the key corresponding to the key identifier.

System.ArgumentNullException

encryptParameters is null.

System.Security.Cryptography.CryptographicException

The local cryptographic provider threw an exception.

System.InvalidOperationException

The key is invalid for the current operation.

System.NotSupportedException

The operation is not supported with the specified key.

Applies to

EncryptAsync(EncryptionAlgorithm, Byte[], CancellationToken)

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

plaintext
System.Byte[]

The data to encrypt.

cancellationToken
System.Threading.CancellationToken

A System.Threading.CancellationToken to cancel the operation.

Returns

System.Threading.Tasks.Task<EncryptResult>

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 server returned an error. See System.Exception.Message for details returned from the server.

System.ArgumentException

The specified algorithm does not match the key corresponding to the key identifier.

System.Security.Cryptography.CryptographicException

The local cryptographic provider threw an exception.

System.InvalidOperationException

The key is invalid for the current operation.

System.NotSupportedException

The operation is not supported with the specified key.

Applies to