encrypt

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

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.

See Common parameters and headers for headers and parameters that are used by all requests.

In your request:

  • Provide the name of the key to encrypt using {key-name} in the request URL.
  • Adding the key-version parameter, …/keys/{key-name}/{key-version}… , encrypts using a specific version of a key.

For more information, see About keys, secrets, and certificates and Authentication, requests and responses.

POST https://{vaultBaseUrl}/keys/{key-name}/{key-version}/encrypt?api-version={api-version}

URI Parameters

Name In Required Type Description
vaultBaseUrl
path True
  • string

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

key-name
path True
  • string

The name of the key.

key-version
path True
  • string

The version of the key.

api-version
query True
  • string

Use the latest service version, 2016-10-01.

Request Body

Name Required Type Description
alg True
  • enum:
    • RSA-OAEP
    • RSA-OAEP-256
    • RSA1_5

algorithm identifier

value True
  • string
    base64url

Responses

Name Type Description
200 OK

The encryption result.

Other Status Codes

Key Vault error response describing why the operation failed.

Definitions

Error

The key vault server error.

KeyOperationResult
KeyVaultError

The key vault server error.

Name Type Description
code
  • string

The error code.

innererror
message
  • string

The error message.

Name Type Description
kid
  • string

Key identifier

value
  • string
    base64url
Name Type Description
error

The key vault server error.