Пример #1
0
        public async Task <byte[]> EncryptAsync(
            byte[] plaintext,
            IEnumerable <KeyValuePair <string, string> >?aad = null)
        {
            var request = new EncryptRequest(keyId, plaintext, GetEncryptionContext(aad));

            var result = await client.EncryptAsync(request).ConfigureAwait(false);

            return(result.CiphertextBlob);
        }
Пример #2
0
        public async Task <byte[]> EncryptAsync(byte[] data, IDictionary <string, string> context = null)
        {
            #region Preconditions

            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            if (data.Length > 1024 * 4)
            {
                throw new ArgumentException("Must be less than 4KB", nameof(data));
            }

            #endregion

            var request = new EncryptRequest(keyId, data, context != null ? new JsonObject(context) : null);

            var result = await client.EncryptAsync(request).ConfigureAwait(false);

            return(result.CiphertextBlob);
        }
Пример #3
0
        public async Task <byte[]> EncryptAsync(
            byte[] plaintext,
            IEnumerable <KeyValuePair <string, string> > aad = null)
        {
            #region Preconditions

            if (plaintext == null)
            {
                throw new ArgumentNullException(nameof(plaintext));
            }

            if (plaintext.Length > 1024 * 4)
            {
                throw new ArgumentException("Must be less than 4KB", nameof(plaintext));
            }

            #endregion

            var request = new EncryptRequest(keyId, plaintext, GetEncryptionContext(aad));

            var result = await client.EncryptAsync(request).ConfigureAwait(false);

            return(result.CiphertextBlob);
        }
Пример #4
0
 public Task <EncryptResponse> EncryptAsync(EncryptRequest request)
 {
     return(SendAsync <EncryptResponse>("Encrypt", request));
 }
Пример #5
0
 public Task <EncryptResponse> EncryptAsync(EncryptRequest request) =>
 SendAsync <EncryptResponse>("Encrypt", request);