private static void DecryptData(KmsClient kmsClient) { try { var request = new DecryptDataRequest { VersionId = "v1.0", Body = new DecryptDataRequestBody() { CipherText = EncryptData(kmsClient).CipherText } }; var resp = kmsClient.DecryptData(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); } }
/// <summary> /// 解密数据 /// </summary> public async Task <DecryptDataResponse> DecryptDataAsync(DecryptDataRequest decryptDataRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add("version_id", decryptDataRequest.VersionId.ToString()); string urlPath = HttpUtils.AddUrlPath("/{version_id}/{project_id}/kms/decrypt-data", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, "application/json;charset=UTF-8", decryptDataRequest); HttpResponseMessage response = await DoHttpRequestAsync("POST", request); return(JsonUtils.DeSerialize <DecryptDataResponse>(response)); }