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

The base62 representation of a KSUID shouldn't have less than 27 characters #9

Open
ManuelZ opened this issue Oct 27, 2021 · 0 comments

Comments

@ManuelZ
Copy link

ManuelZ commented Oct 27, 2021

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.

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

No branches or pull requests

1 participant