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

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 a length limit the caller sets, bech32_decode's docstring giving the default and why, 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)

ARCHITECTURE.md says how these modules layer and which may import which.

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, m = bech32.bech32_decode("bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4")
# BIP350: bech32 for witness version 0, bech32m for every later one
assert m == (bech32.BECH32_1_CONST if values[0] == 0 else bech32.BECH32_M_CONST)
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

Development is LLM-based: humans are welcome, as long as they are comfortable with agentic development ;-). A contribution must have been read and understood by the person who submits it. CONTRIBUTING.md has the rules.

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.

Status

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


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

Metadata

Release files for base58-bech32 2026.11.12

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.11.12
File Size Uploaded Provenance Actions
base58_bech32-2026.11.12.tar.gz 586.9 kB With provenance Details for base58_bech32-2026.11.12.tar.gz

Built distribution (wheel)

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

Total release size: 616.7 kB

Release files / base58_bech32-2026.11.12.tar.gz

Download URL base58_bech32-2026.11.12.tar.gz
Size 586.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ce5c53698925e64f34fc56dfd3619193662798fd13d3458237e08a0d4305be3e
BLAKE2b-256 checksum
How to use checksums
eb95f4e172008b7457777b1e4a242584d7f0372e7c373f199fec2a2ba1e2b93b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 12, 2026.

Transparency log

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

Download URL base58_bech32-2026.11.12-py3-none-any.whl
Size 29.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
355580ddd883a94da6176ab05ebf638257e4f457c0ba2d1a452028ae976c7a3c
BLAKE2b-256 checksum
How to use checksums
158de3d0ec7801c9a28a1394ba094483081988dfbb60ce737e8849c7b3318f00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 12, 2026.

Transparency log

Security for base58-bech32 2026.11.12

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for base58_bech32-2026.11.12.tar.gz

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 Nov 12, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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