private static void EncryptDataKey(KmsClient kmsClient) { try { var data = DecryptDataKey(kmsClient); var plainText = data.DataKey + data.DatakeyDgst; var request = new EncryptDatakeyRequest { VersionId = "v1.0", Body = new EncryptDatakeyRequestBody() { KeyId = GetKeyByStatus.GetKeyByKeyStatus(kmsClient, "2"), DatakeyPlainLength = "64", PlainText = plainText } }; var resp = kmsClient.EncryptDatakey(request); Console.WriteLine(resp.ToString()); } catch (RequestTimeoutException requestTimeoutException) { Console.WriteLine(requestTimeoutException.ErrorMessage); } catch (ServiceResponseException clientRequestException) { Console.WriteLine(clientRequestException.HttpStatusCode); Console.WriteLine(clientRequestException.ErrorCode); Console.WriteLine(clientRequestException.ErrorMsg); } catch (ConnectionException connectionException) { Console.WriteLine(connectionException.ErrorMessage); } }