Amazon.KeyManagementService.AmazonKeyManagementServiceClient.Encrypt C# (CSharp) Method

Encrypt() public method

Encrypts plaintext into ciphertext by using a customer master key. The Encrypt function has two primary use cases:
  • You can encrypt up to 4 KB of arbitrary data such as an RSA key, a database password, or other sensitive customer information.

  • If you are moving encrypted data from one region to another, you can use this API to encrypt in the new region the plaintext data key that was used to encrypt the data in the original region. This provides you with an encrypted copy of the data key that can be decrypted in the new region and used there to decrypt the encrypted data.

Unless you are moving encrypted data from one region to another, you don't use this function to encrypt a generated data key within a region. You retrieve data keys already encrypted by calling the GenerateDataKey or GenerateDataKeyWithoutPlaintext function. Data keys don't need to be encrypted again by calling Encrypt.

If you want to encrypt data locally in your application, you can use the GenerateDataKey function to return a plaintext data encryption key and a copy of the key encrypted under the customer master key (CMK) of your choosing.

/// The system timed out while trying to fulfill the request. The request can be retried. /// /// The request was rejected because the specified CMK is not enabled. /// /// The request was rejected because the specified grant token is not valid. /// /// The request was rejected because the specified KeySpec value is not valid. /// /// The request was rejected because the specified CMK was not available. The request /// can be retried. /// /// The request was rejected because an internal exception occurred. The request can be /// retried. /// /// The request was rejected because the state of the specified resource is not valid /// for this request. /// /// /// /// For more information about how key state affects the use of a CMK, see How /// Key State Affects Use of a Customer Master Key in the AWS Key Management Service /// Developer Guide. /// /// /// The request was rejected because the specified entity or resource could not be found. ///
public Encrypt ( EncryptRequest request ) : EncryptResponse
request EncryptRequest Container for the necessary parameters to execute the Encrypt service method.
return EncryptResponse
        public EncryptResponse Encrypt(EncryptRequest request)
        {
            var marshaller = new EncryptRequestMarshaller();
            var unmarshaller = EncryptResponseUnmarshaller.Instance;

            return Invoke<EncryptRequest,EncryptResponse>(request, marshaller, unmarshaller);
        }
AmazonKeyManagementServiceClient