ahawker / ulid

Universally Unique Lexicographically Sortable Identifier (ULID) in Python 3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ULID.hex skips leading zero

xkortex opened this issue · comments

ulid-py 1.1.0

The .hex attribute does not correctly pad to 32 characters. It skips the leading zero, giving a len-31 string (33 with the 0x).

import ulid
import binascii 

u = ulid.from_randomness(0)
print(len(u.hex))
print(u.hex)
print(f"0x{binascii.hexlify(u.bytes).decode()}")

Out:

33
0x17b0c9d5b3b00000000000000000000
0x017b0c9d5b3b00000000000000000000