I was watching a tutorial regarding system design for tiny url, and reading up on base62 encoding to avoid collision. They say to use a counter, and encode it with base62. Now this makes sense but looking at some online base62encoder, if the tiny url limit character say only 7 characters, if some of the encoder generate more than 7 characters.
Are there multiple type of base62 encoding? e.g this two websites, gives 2 different result for same input of 1000000
Base62 and Base64 encodings are used to represent binary data as text.
I am not sure what practical use base62
has. base64
, on another hand, can represent 6 bits as one character, Your sample value 1,000,000
(hex 0xF4240
) uses 20 bits, so it fits into 4 base64
characters.
Your first example uses a plain text 1000000
, which is 7 characters, 8-bit each. Or total of 56 characters, that would require 10 base64
characters.
You will get similar numbers for base62
, but the encoding must be non-trivial, as you can't simply chop your data into 6-bits pieces.
Wiki link above mentions multiple variants, so you do have to agree between encoder and decoder - which one to use. But this is NOT the issue you saw in your two examples.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With