public byte[] EncryptKey(byte[] plainText, IDictionary <string, string> context) { var req = new EncryptRequest { KeyId = _keyId, Plaintext = new MemoryStream(plainText), EncryptionContext = AsDictionary(context) }; return(_client.Encrypt(req).CiphertextBlob.ToArray()); }
private Amazon.KeyManagementService.Model.EncryptResponse CallAWSServiceOperation(IAmazonKeyManagementService client, Amazon.KeyManagementService.Model.EncryptRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Key Management Service", "Encrypt"); try { #if DESKTOP return(client.Encrypt(request)); #elif CORECLR return(client.EncryptAsync(request).GetAwaiter().GetResult()); #else #error "Unknown build edition" #endif } catch (AmazonServiceException exc) { var webException = exc.InnerException as System.Net.WebException; if (webException != null) { throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); } throw; } }