The base62 representation of a KSUID shouldn't have less than 27 characters
Opened this issue · 0 comments
ManuelZ commented
From here:
“The text representation is always 27 characters, encoded in alphanumeric base62 that will lexicographically sort by timestamp.”
Passing in a timestamp close to the epoch can produce a bytes representation with leading zeros after the epoch has been substracted, which produces KSUIDs with a base62 representation with a length less than 27.
from ksuid import ksuid
EPOCH = int(14e8) # '2014-05-13T16:53:20'
>>> k = ksuid(EPOCH)
>>> k.toBase62()
'39kHQVbzU2HGjKozI65P4b'
>>> len(k.toBase62())
22
In the Go implementation, a left zero padding is done.
Using the version from master.