question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Non-Crockford's Base32 letters converted differently in Java or Python implementations

See original GitHub issue

Hi 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:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ahawkercommented, Oct 26, 2017

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

0reactions
eberbiscommented, Oct 29, 2017

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Properly handle invalid base32 characters · Issue #60
As of today, it is possible to input non-base32 characters, ... Non-Crockford's Base32 letters converted differently in Java or Python ...
Read more >
python - How to use a different alphabet for Base32 classes?
I've been told that I should initialize the Crypto++ Base32 implementation to use a different alphabet than the default.
Read more >
The Base16, Base32, and Base64 Data Encodings
Implementations MUST NOT add line feeds to base-encoded data unless the specification ... The base64 and base32 alphabets use padding, as described below...
Read more >
Base32 - Wikipedia
Base32 is the base-32 numeral system. It uses a set of 32 digits, each of which can be represented by 5 bits (2...
Read more >
RFC 3548 - The Base16, Base32, and Base64 Data ...
For base 16 and base 32, this determines the use of upper- or lowercase alphabets. For base 64, the non-alphanumeric characters (in particular...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found