Ejemplo n.º 1
0
        private static EncryptDataResponse EncryptData(KmsClient kmsClient)
        {
            try
            {
                var request = new EncryptDataRequest
                {
                    VersionId = "v1.0",
                    Body      = new EncryptDataRequestBody()
                    {
                        KeyId     = GetKeyByStatus.GetKeyByKeyStatus(kmsClient, "2"),
                        PlainText = "hello world"
                    }
                };
                var resp = kmsClient.EncryptData(request);
                Console.WriteLine(resp.ToString());
                return(resp);
            }
            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);
            }

            return(null);
        }