Skip to main content

base58-bech32

Base58, Base58Check, bech32, bech32m, SS58 and CashAddr: the binary-to-text codecs of cryptocurrency addresses and keys, in typed Python, with nothing of any chain above them.

PyPI version GitHub release development status license downloads supported Python versions implementation wheel

pre-commit.ci status lint workflow status test workflow status docs workflow status documentation build vendored-vectors workflow status mutation workflow status fuzz workflow status deps-latest workflow status pypi-install workflow status deps-oldest workflow status os-macos workflow status os-ubuntu workflow status os-windows workflow status links workflow status sdist-rebuild workflow status codeql workflow status

OpenSSF Scorecard OpenSSF Best Practices OpenSSF Baseline

It is fully annotated and ships py.typed, and it imports nothing but the standard library.

What is here

  • Base58, plain and checked: Bitcoin's alphabet, Ripple's, or any other 58 distinct ascii bytes, and Base58Check's double SHA-256 checksum (base58)
  • bech32 and bech32m, with no length limit, and convertbits, the regrouping of bytes into 5-bit values and back (bech32)
  • SS58, the address format of Polkadot and the Substrate chains, with both prefix forms (ss58)
  • CashAddr, the address format of Bitcoin Cash (cashaddr)

Every refusal is a ValueError or a TypeError, under one base, Base58Bech32Exception (exceptions). No decoder's refusal quotes the string it was handed: what reaches a decoder can be a private key.

What the bytes mean -- a witness program, a public key hash, a WIF -- is not here: btclib is the library above this one for bitcoin. The migration page maps each function of the base58 and bech32 packages to its equivalent here.

The suite answers to vectors their authors publish -- Bitcoin Core's, the base58 package's, Substrate's and the CashAddr specification's -- and tests/_data/README.md pins each vendored file to the upstream commit it was copied from.

Installing

python -m pip install --upgrade base58-bech32

An address of each format

from base58_bech32 import base58, bech32, cashaddr, ss58

wif = base58.b58encode_check(bytes.fromhex("80" + "11" * 32 + "01"))
assert base58.b58decode_check(wif, out_size=34)[0] == 0x80

hrp, values = bech32.bech32_decode("bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4")
program = bytes(bech32.convertbits(values[1:], 5, 8, False))
assert (hrp, values[0], program.hex()[:8]) == ("bc", 0, "751e76e8")

alice = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"
prefix, account = ss58.ss58_decode(alice)
assert prefix == 42
polkadot = ss58.ss58_encode(0, account)
assert polkadot == b"15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5"

address = "bitcoincash:qr6m7j9njldwwzlg9v7v53unlr4jkmx6eylep8ekg2"
assert cashaddr.cashaddr_decode(address)[:2] == ("bitcoincash", 0)

tests/readme_test.py runs every Python block of this file, so the example above is the one the suite checks.

Security

SECURITY.md says how to report a vulnerability, which versions are supported, and how a published file is traced back to the run that built it. ASSURANCE_CASE.md argues why what it promises holds: the threat model, the trust boundaries, and the weaknesses a package of this kind is exposed to.

Contributing

CONTRIBUTING.md has the commands each CI job runs, verbatim. uv sync creates the environment; uv is the only tool that has to be installed. REVIEWING.md is what a pull request is answered against.

How the organization decides, and who holds which role, is its GOVERNANCE.md; what it intends to do, and what it deliberately does not, is its ROADMAP.md.


The btclib organization and its projects are actively supported by DGI and CheckSig.

Metadata

Release files for base58-bech32 2026.10.18

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for base58-bech32 2026.10.18
File Size Uploaded
base58_bech32-2026.10.18.tar.gz 543.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for base58-bech32 2026.10.18
File Interpreter ABI Platform
base58_bech32-2026.10.18-py3-none-any.whl Python 3 none any Details

Total release size: 569.7 kB

Release files / base58_bech32-2026.10.18.tar.gz

Download URL base58_bech32-2026.10.18.tar.gz
Size 543.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8dca3d3fe2b3e78f4dace2b3c875f41e61d1d2b5c8f66577aedb84a155fc57a5
BLAKE2b-256 checksum
How to use checksums
340f5ac4eef01c578dabe5bffd872edc3acd799287e871fba9612a348d5a9394
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

Release files / base58_bech32-2026.10.18-py3-none-any.whl

Download URL base58_bech32-2026.10.18-py3-none-any.whl
Size 26.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5aaa0d32d64aaf80e43e96a423dd49634b679d9a5c688cac38e8be1cf2b7cf66
BLAKE2b-256 checksum
How to use checksums
85791148eee315ff8a4b128b7260a30478d6d9af3fde73f74b1742d73b93e607
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2026.10.18 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page