private async ValueTask <EncryptionData> Encrypt(EncryptionData rawData) { await using Stream decStream = rawData.DecryptedStream !; await using Stream encStream = await _encryptionProvider.EncryptAsync(decStream); return(await EncryptionData.From(encStream, null)); }
private async ValueTask <EncryptionData> Decrypt(EncryptionData rawData) { await using Stream encStream = rawData.EncryptedStream !; await using Stream decStream = await _encryptionProvider.DecryptAsync(encStream); SaveFileHandler.RemoveTrailingZeroes(decStream); return(await EncryptionData.From(null, decStream)); }
private static async ValueTask <EncryptionData> CallEndpoint(Stream?encrypted, Stream?decrypted, string endpoint) { using HttpContent content = new StringContent(JsonSerializer.Serialize(await EncryptionData.From(encrypted, decrypted))); content.Headers.ContentType.MediaType = "application/json"; HttpResponseMessage response = await Client.PostAsync(endpoint, content); return(JsonSerializer.Deserialize <EncryptionData>(await response.Content.ReadAsStringAsync(), SerializerOptions)); }