Non-Crockford's Base32 letters converted differently in Java or Python implementations
See original GitHub issueHi Andrew,
first of all, thanks for the amazing library, we’ve been using a lot!
I have a doubt regarding how we fix the conversion of ULIDs which are not following Crockford’s Base32 standard.
We are using Lua to generate some guids (https://github.com/Tieske/ulid.lua) and for some reason, we get from time to time letters outside the Crockford’s Base32. While trying to fix this on our side (we’re not sure how this is happening to be honest), we realised that Java and Python implementations silently corrects this issue in different ways:
Java
ULID.Value ulidValueFromString = ULID.parseULID("01BX73KC0TNH409RTFD1JXKmO0")
--> "01BX73KC0TNH409RTFD1JXKM00"
mO
is silently converted into M0
Python
In [1]: import ulid
In [2]: u = ulid.from_str('01BX73KC0TNH409RTFD1JXKmO0')
In [3]: u
Out[3]: <ULID('01BX73KC0TNH409RTFD1JXKQZ0')>
In [4]: u.str
Out[4]: '01BX73KC0TNH409RTFD1JXKQZ0'
mO
is silently converted into QZ
Shouldn’t the python library behave as the Java one as per the Crockford’s Base32 spec, converting L
and I
to 1
and O
to 0
and only upper casing lower case letters instead of changing them?
Thanks a lot in advance!
Eddie
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
Eddie,
Thanks again for reporting this and I apologize for the issue!
I merged in a fix and pushed out version
0.0.5
that should address it.Best, Andrew
Thanks Andrew,
just made a few examples on my local and now it raises a
ValueError
if there’s a non-base32 character found.Thanks again for the swift response to this!
Eddie