Base58

raw JSON →
0.1.1 verified Fri May 01 auth: no python

A fast Python library for Base58 and Base58Check encoding/decoding. Version 0.1.1 supports Python >=3.7. Development is active with releases on a monthly cadence.

pip install based58
error ImportError: cannot import name 'base58_encode' from 'base58'
cause Mistakenly using the 'base58' library instead of 'based58'.
fix
Run 'pip install based58' and change import to 'from based58 import base58_encode'.
error TypeError: expected bytes-like object, not str
cause Passing a string directly to base58_encode or base58_decode.
fix
Encode the string: base58_encode('hello'.encode())
error AttributeError: module 'based58' has no attribute 'b58encode'
cause Using API naming from the 'base58' library on 'based58'.
fix
Use base58_encode instead of b58encode, e.g., 'from based58 import base58_encode'.
gotcha Do not confuse with the 'base58' library. Both provide 'base58_encode'/'base58_decode' but are entirely different packages. Check your requirements file.
fix Use 'pip install based58' and import from 'based58'.
deprecated As of version 0.1.1, the general 'encode'/'decode' functions are not provided; only bytes-to-bytes functions. Do not expect string-in/string-out behavior.
fix Ensure input is bytes, not str. Use .encode() or .decode() as needed.
gotcha The library expects input to be bytes. Passing a string will raise AttributeError or TypeError depending on Python version.
fix Convert strings to bytes: base58_encode('text'.encode()).

Encode and decode bytes using Base58.

from based58 import base58_encode, base58_decode

encoded = base58_encode(b'hello world')
print(encoded)  # b'STV9KUJUjQJRyv7'
decoded = base58_decode(encoded)
print(decoded)  # b'hello world'