Skip to content
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

Custom alphabet option #63

Open
dfahlander opened this issue Feb 4, 2025 · 1 comment
Open

Custom alphabet option #63

dfahlander opened this issue Feb 4, 2025 · 1 comment

Comments

@dfahlander
Copy link

This might be an addon proposal as this proposal has already reached implementations.

When it comes to comparision and sorting, base64 does not preserve the sort order from the original array. This is possible to achieve by using another alphabet that preserves the lexical order of the orignal array as long as arrays are of the same lengths.

Could it be an option to provide a custom alphabet else than base64 and base64url? If the alphabet option would be something like {custom: string} it might allow for using a custom alphabet?

Implementations examples and related articles:

@bakkot
Copy link
Collaborator

bakkot commented Feb 4, 2025

It would have to be a followup proposal, but yes, it could be done - the two values for the alphabet option are much shorter than any valid alphabet, so a straightforward extension would be to also allow a length-64 string to use as the alphabet. There would need to be a strong motivation, however, and I don't think the sorting use case comes up often enough to be a motivation on its own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants