base62
base62 copied to clipboard
Is it base62 or (non-standard) base64 encoding?
In base62.go
:
const encodeStd = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-0123456789."
there are 64 symbols.
UPD: I also noted there is a fork.
Yeah, this confused me, so I forked it to be sure. No idea why those are in there. I'll submit it as a PR.
For anyone else stumbling across this: You won't find a working base62 impl in here.
Try https://github.com/eknkc/basex instead, which has perfect support for base62 and other encodings.
Here is another high performance implementation https://github.com/jxskiss/base62
@jxskiss Your library is encoding things backwards - meaning that it reverses the byte order of the input when producing the output.
So [0, 0, 0, 0, 255, 255, 255, 255]
becomes:
// Using the base64-like alphabet ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
ffffffDAAAAA
// Using the GMP-like alphabet 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
VVVVVV300000
And I'm not clear that simply reversing the string would be the correct implementation.
@coolaj86 Simply reversing the string wouldn't be a correct implementation -_- The reversing order you see is just an implementation detail, the correctness is tested by large amount of random bytes data.
You may get more details here https://github.com/jxskiss/base62/issues/2#issuecomment-999554395