Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Consider implementing Base64url transformation #1808

Closed
ycrumeyrolle opened this issue Oct 2, 2017 · 5 comments
Closed

Consider implementing Base64url transformation #1808

ycrumeyrolle opened this issue Oct 2, 2017 · 5 comments
Labels
area-System.Text.Primitives OpenBeforeArchiving These issues were open before the repo was archived. For re-open them, file them in the new repo up-for-grabs
Milestone

Comments

@ycrumeyrolle
Copy link

Base64url is widely used by web applications.
Current implementations are based on base64 encoding then replacing characters and trimming padding.
It can be optimized by directly implementing the base64url specifics within the main transformation loop.

@GrabYourPitchforks
Copy link
Member

Ideally we'd support base64, base64url, and hex transformations as the first batch when the transformation API design is finalized.

@KrzysztofCwalina
Copy link
Member

The following sample shows how it can be done today: https://github.com/dotnet/corefxlab/blob/master/src/System.Azure.Experimental/System/Azure/CosmosDbAuthorizationHeader.cs#L45

How much more efficient can the specialized encoder be?

@ycrumeyrolle
Copy link
Author

Not sure to understand the sample. It is Base64 encoding, not Base64Url encoding.
If we have to encode in Base64Url in this sample, it is required to replace '+' and '/' characters by '-' and '_', and to trim the trailing '=' .

@KrzysztofCwalina
Copy link
Member

I was just showing how IBufferOperation can be used to combine transformations, wondering if ToBase64Url transformation that swaps the chars a(e.g. + => -) and returns before the trailing == would not be fast enough. I think specialized transformation will be more convenient though.

@ycrumeyrolle
Copy link
Author

Ok I see your point.

Another argument in addition to the performance is the API surface. Just last day I spotted a bug on our API gateway, written in Java. The developers were decoding in Base64 the content, then URL decoding, as there is not explicit Base64Url API.
And sometimes "data corruption" strangely occurred...

@joshfree joshfree added this to the Future milestone Apr 5, 2018
@pgovind pgovind added the OpenBeforeArchiving These issues were open before the repo was archived. For re-open them, file them in the new repo label Mar 11, 2021
@pgovind pgovind closed this as completed Mar 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Text.Primitives OpenBeforeArchiving These issues were open before the repo was archived. For re-open them, file them in the new repo up-for-grabs
Projects
None yet
Development

No branches or pull requests

6 participants