Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Enable ToBase64Transform.CanTransformMultipleBlocks#55055

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
stephentoub merged 2 commits intodotnet:mainfromstephentoub:cantransformtrue
Jul 6, 2021

Conversation

@stephentoub
Copy link
Member

@stephentoubstephentoub commentedJul 2, 2021
edited
Loading

Fixes#55029

MethodToolchainMeanRatioAllocated
Encode\main\corerun.exe107,747,075.7 ns1.003,686 B
Encode\pr\corerun.exe2,269,515.9 ns0.02210 B
usingBenchmarkDotNet.Attributes;usingBenchmarkDotNet.Columns;usingBenchmarkDotNet.Configs;usingBenchmarkDotNet.Diagnosers;usingBenchmarkDotNet.Reports;usingBenchmarkDotNet.Running;usingPerfolizer.Horology;usingSystem;usingSystem.Globalization;usingSystem.IO;usingSystem.Security.Cryptography;[MemoryDiagnoser]publicclassProgram{publicstaticvoidMain(string[]args)=>BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args,DefaultConfig.Instance.WithSummaryStyle(newSummaryStyle(CultureInfo.InvariantCulture,printUnitsInHeader:false,sizeUnit:SizeUnit.B,timeUnit:TimeUnit.Nanosecond,printZeroValuesInContent:true)));privatebyte[]_data=RandomNumberGenerator.GetBytes(10_000_000);privateMemoryStream_destination=newMemoryStream();[Benchmark]publicvoidEncode(){_destination.Position=0;using(vartoBase64=newToBase64Transform())using(varstream=newCryptoStream(_destination,toBase64,CryptoStreamMode.Write,leaveOpen:true)){Span<byte>remaining=_data;while(!remaining.IsEmpty){Span<byte>toWrite=remaining.Slice(0,Math.Min(4096,remaining.Length));stream.Write(toWrite);remaining=remaining.Slice(toWrite.Length);}}}}

@ghost
Copy link

Tagging subscribers to this area:@bartonjs,@vcsjones,@krwq,@GrabYourPitchforks
See info inarea-owners.md if you want to be subscribed.

Issue Details

Fixes#55029

MethodToolchainMeanRatioAllocated
Encode\main\corerun.exe107,747,075.7 ns1.003,686 B
Encode\pr\corerun.exe2,269,515.9 ns0.02210 B
usingBenchmarkDotNet.Attributes;usingBenchmarkDotNet.Configs;usingBenchmarkDotNet.Running;usingSystem;usingBenchmarkDotNet.Diagnosers;usingPerfolizer.Horology;usingBenchmarkDotNet.Columns;usingSystem.Globalization;usingBenchmarkDotNet.Reports;usingSystem.Security.Cryptography;usingSystem.IO;[MemoryDiagnoser]publicclassProgram{publicstaticvoidMain(string[]args)=>BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args,DefaultConfig.Instance.WithSummaryStyle(newSummaryStyle(CultureInfo.InvariantCulture,printUnitsInHeader:false,sizeUnit:SizeUnit.B,timeUnit:TimeUnit.Nanosecond,printZeroValuesInContent:true)));privatebyte[]_data=RandomNumberGenerator.GetBytes(10_000_000);privateMemoryStream_destination=newMemoryStream();[Benchmark]publicvoidEncode(){_destination.Position=0;using(vartoBase64=newToBase64Transform())using(varstream=newCryptoStream(_destination,toBase64,CryptoStreamMode.Write,leaveOpen:true)){Span<byte>remaining=_data;while(!remaining.IsEmpty){Span<byte>toWrite=remaining.Slice(0,Math.Min(4096,remaining.Length));stream.Write(toWrite);remaining=remaining.Slice(toWrite.Length);}}}}
Author:stephentoub
Assignees:-
Labels:

area-System.Security

Milestone:6.0.0

@stephentoub
Copy link
MemberAuthor

I'm realizing now I misunderstood the contract, and the implementation needs to be much more complex, to handle cases where more input is provided than can fit into the output space provided... I was only encoding what would fit, but it appears the contract actually requires the remaining input data to be saved off for later.

@stephentoub
Copy link
MemberAuthor

Turns out the implementation doesn't need to be more complex as it can make simplifying assumptions about the inputs, ala what UniversalCryptoTransform does. And since this never previously supported anything other than one input block that entirely fit into the output, this won't be a breaking change. I'll fix up the input validation accordingly.

@stephentoubstephentoub merged commitae5ee8f intodotnet:mainJul 6, 2021
@stephentoubstephentoub deleted the cantransformtrue branchJuly 6, 2021 20:42
@ghostghost locked asresolvedand limited conversation to collaboratorsAug 5, 2021
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@GrabYourPitchforksGrabYourPitchforksGrabYourPitchforks left review comments

@bartonjsbartonjsbartonjs approved these changes

+1 more reviewer

@TornhoofTornhoofTornhoof left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

6.0.0

Development

Successfully merging this pull request may close these issues.

ToBase64Transform wholly inadequate to live in the BCL

4 participants

@stephentoub@GrabYourPitchforks@Tornhoof@bartonjs

[8]ページ先頭

©2009-2025 Movatter.jp