Share via


KeyVaultClientExtensions.EncryptAsync Method

Definition

Overloads

EncryptAsync(IKeyVaultClient, String, String, Byte[], CancellationToken)

Encrypts a single block of data. The amount of data that may be encrypted is determined by the target key type and the encryption algorithm.

EncryptAsync(IKeyVaultClient, String, String, String, String, Byte[], CancellationToken)

Encrypts an arbitrary sequence of bytes using an encryption key that is stored in a key vault.

EncryptAsync(IKeyVaultClient, String, String, Byte[], CancellationToken)

Source:
KeyVaultClientExtensions.cs

Encrypts a single block of data. The amount of data that may be encrypted is determined by the target key type and the encryption algorithm.

public static System.Threading.Tasks.Task<Microsoft.Azure.KeyVault.Models.KeyOperationResult> EncryptAsync (this Microsoft.Azure.KeyVault.IKeyVaultClient operations, string keyIdentifier, string algorithm, byte[] plainText, System.Threading.CancellationToken cancellationToken = default);
static member EncryptAsync : Microsoft.Azure.KeyVault.IKeyVaultClient * string * string * byte[] * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.KeyVault.Models.KeyOperationResult>
<Extension()>
Public Function EncryptAsync (operations As IKeyVaultClient, keyIdentifier As String, algorithm As String, plainText As Byte(), Optional cancellationToken As CancellationToken = Nothing) As Task(Of KeyOperationResult)

Parameters

operations
IKeyVaultClient
keyIdentifier
String

The full key identifier

algorithm
String

The algorithm. For more information on possible algorithm types, see JsonWebKeyEncryptionAlgorithm.

plainText
Byte[]

The plain text

cancellationToken
CancellationToken

Optional cancellation token

Returns

The encrypted text

Applies to

EncryptAsync(IKeyVaultClient, String, String, String, String, Byte[], CancellationToken)

Source:
KeyVaultClientExtensions.cs

Encrypts an arbitrary sequence of bytes using an encryption key that is stored in a key vault.

public static System.Threading.Tasks.Task<Microsoft.Azure.KeyVault.Models.KeyOperationResult> EncryptAsync (this Microsoft.Azure.KeyVault.IKeyVaultClient operations, string vaultBaseUrl, string keyName, string keyVersion, string algorithm, byte[] value, System.Threading.CancellationToken cancellationToken = default);
static member EncryptAsync : Microsoft.Azure.KeyVault.IKeyVaultClient * string * string * string * string * byte[] * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.KeyVault.Models.KeyOperationResult>
<Extension()>
Public Function EncryptAsync (operations As IKeyVaultClient, vaultBaseUrl As String, keyName As String, keyVersion As String, algorithm As String, value As Byte(), Optional cancellationToken As CancellationToken = Nothing) As Task(Of KeyOperationResult)

Parameters

operations
IKeyVaultClient

The operations group for this extension method.

vaultBaseUrl
String

The vault name, for example https://myvault.vault.azure.net.

keyName
String

The name of the key.

keyVersion
String

The version of the key.

algorithm
String

algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA-OAEP-256', 'RSA1_5'

value
Byte[]
cancellationToken
CancellationToken

The cancellation token.

Returns

Remarks

The ENCRYPT operation encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key Vault. Note that the ENCRYPT operation only supports a single block of data, the size of which is dependent on the target key and the encryption algorithm to be used. The ENCRYPT operation is only strictly necessary for symmetric keys stored in Azure Key Vault since protection with an asymmetric key can be performed using public portion of the key. This operation is supported for asymmetric keys as a convenience for callers that have a key-reference but do not have access to the public key material. This operation requires the keys/encypt permission.

Applies to