New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CryptoStream.FlushFinalBlockAsync method missing #38076
Comments
Tagging subscribers to this area: @tarekgh |
cc @bartonjs |
It looks like the Line 106 in 643f5e1
Though a public version is not directly exposed. However, Assuming you are done with the Line 695 in 643f5e1
This might be a good work around for now instead of setting |
@stephentoub It doesn't look like it occurred to me to ask the question back then (dotnet/corefx#33422), but: Did you consider adding I'm guessing it was just a narrow scope of "override DisposeAsync in all the right places" |
I don't think I considered it.
Yup. |
Seems like we can do partial class CryptoStream
{
public ValueTask FlushFinalBlockAsync(CancellationToken cancellationToken = default) =>
FlushFinalBlockAsync(useAsync: true, cancellationToken);
} And plumb the token into all of the relevant places in the existing private FlushFinalBlockAsync(bool) |
Looks good as proposed. namespace System.Security.Cryptography
{
partial class CryptoStream
{
public ValueTask FlushFinalBlockAsync(CancellationToken cancellationToken = default);
}
} |
Background and Motivation
I'm creating a web API for file encryption with an AES Key. I creates an helper functions that generate an instance of EncryptedFileResult (an extension of ActionResult class that I created) where I encrypt the file.
I override the two methods ExecuteResult and ExecuteResultAsync.
The body of ExecuteResultAsync is the next:
When the program runs, at the line
fs.FlushFinalBlock();
, it generates an exception:For the moment I set the AllowSynchronousIO to true, but it will be good to have an async overload for the FlushFinalBlock, to have the benefits of async methods.
I would like to implements it.
Proposed API
Usage Examples
Previous code could be this:
The text was updated successfully, but these errors were encountered: