CryptographyClient.Encrypt 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
Encrypt(EncryptionAlgorithm, Byte[], CancellationToken) |
Encrypts the specified plaintext. |
Encrypt(EncryptParameters, CancellationToken) |
Encrypts plaintext. |
Encrypt(EncryptionAlgorithm, Byte[], CancellationToken)
- Source:
- CryptographyClient.cs
- Source:
- CryptographyClient.cs
Encrypts the specified plaintext.
public virtual Azure.Security.KeyVault.Keys.Cryptography.EncryptResult Encrypt (Azure.Security.KeyVault.Keys.Cryptography.EncryptionAlgorithm algorithm, byte[] plaintext, System.Threading.CancellationToken cancellationToken = default);
abstract member Encrypt : Azure.Security.KeyVault.Keys.Cryptography.EncryptionAlgorithm * byte[] * System.Threading.CancellationToken -> Azure.Security.KeyVault.Keys.Cryptography.EncryptResult
override this.Encrypt : Azure.Security.KeyVault.Keys.Cryptography.EncryptionAlgorithm * byte[] * System.Threading.CancellationToken -> Azure.Security.KeyVault.Keys.Cryptography.EncryptResult
Public Overridable Function Encrypt (algorithm As EncryptionAlgorithm, plaintext As Byte(), Optional cancellationToken As CancellationToken = Nothing) As 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
Encrypt(EncryptParameters, CancellationToken)
- Source:
- CryptographyClient.cs
- Source:
- CryptographyClient.cs
Encrypts plaintext.
public virtual Azure.Security.KeyVault.Keys.Cryptography.EncryptResult Encrypt (Azure.Security.KeyVault.Keys.Cryptography.EncryptParameters encryptParameters, System.Threading.CancellationToken cancellationToken = default);
abstract member Encrypt : Azure.Security.KeyVault.Keys.Cryptography.EncryptParameters * System.Threading.CancellationToken -> Azure.Security.KeyVault.Keys.Cryptography.EncryptResult
override this.Encrypt : Azure.Security.KeyVault.Keys.Cryptography.EncryptParameters * System.Threading.CancellationToken -> Azure.Security.KeyVault.Keys.Cryptography.EncryptResult
Public Overridable Function Encrypt (encryptParameters As EncryptParameters, Optional cancellationToken As CancellationToken = Nothing) As 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.