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

Which base62 algorithm does this implement? #29

Open
coolaj86 opened this issue Dec 16, 2021 · 2 comments
Open

Which base62 algorithm does this implement? #29

coolaj86 opened this issue Dec 16, 2021 · 2 comments
Labels

Comments

@coolaj86
Copy link

My understanding is that there is no formal spec for base62, but that the "glowfall" implementation (despite its lack of stars) has become the de facto implementation (used the most across the most repos).

Does this follow that spec? Or a different one? Or create a new one?

@tuupola
Copy link
Owner

tuupola commented Dec 17, 2021

Have not heard of glowfall before. This library implements mathematical byte by byte base conversion of arbitrary data. There is really only one way to do it. Standards such as base85 which has extra rules for compressing spaces etc are not pure base conversions.

By default this library uses 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz as character set. It is the same as The GNU Multiple Precision Arithmetic Library uses. GMP has been around since early 1990's. I personally like this character set most since the encoded base62 strings preserve the sort order of the encoded values

@coolaj86
Copy link
Author

I think I was mistaken. The GMP, GnuPG, and Saltpack implementations seem to be the most recognized.

Would you mind giving example output for your implementation compared to these references?

Raw   : "Hello, 世界"
Base64: SGVsbG8sIOS4lueVjA (18 chars)
Base62: 1wJfrzvdbuFbL65vcS (18 chars)

Raw   : "Hello World"
Base64: SGVsbG8gV29ybGQ (15 chars)
Base62: 73XpUgyMwkGr29M (15 chars)

Raw   : [ 0, 0, 0, 0, 255, 255, 255, 255 ]
Base64: AAAAAP____8 (11 chars)
Base62: 000004gfFC3 (11 chars)

Raw   : [ 255, 255, 255, 255, 0, 0, 0, 0 ]
Base64: _____wAAAAA (11 chars)
Base62: LygHZwPV2MC (11 chars)

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

No branches or pull requests

2 participants