`Encode()` produces wrong value when low half of UUID is zero
cpick opened this issue · comments
base57.numToString()
uses number.Uint64()
which is undefined if number
"cannot be represented in a uint64" which is the case since it starts off containing a 128 bit integer.
This causes incorrect encoding of any UUID whose low half bits are all zero (along with any other cases where those bits were zero after some number of divisions by b.alphabet.Length()
).
00000000-0000-0000-8000-000000000000
encodes to "z7C8BNkRBVT22", but 00000000-0000-0001-0000-000000000000
erroneously encodes to "2222222222222" which clashes with the encoding of 00000000-0000-0000-0000-000000000000
as opposed to the expected "yDNELiVqLxt22".