Skip to main content

base58-bech32

Base58, Base58Check, bech32, bech32m, SS58, CashAddr and Stellar's strkey: 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)
  • strkey, the text form of Stellar's account ids, keys and addresses, as a version byte and a payload (strkey)

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 and strkey specifications' -- 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, strkey

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)

account = "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ"
version, key = strkey.strkey_decode(account)
# SEP-0023: 6 << 3 is an ed25519 public key, which the caller checks
assert (version, len(key)) == (6 << 3, 32)
assert strkey.strkey_encode(version, key) == account.encode("ascii")

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.14

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.14
File Size Uploaded Provenance Actions
base58_bech32-2026.11.14.tar.gz 603.4 kB With provenance Details for base58_bech32-2026.11.14.tar.gz

Built distribution (wheel)

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

Total release size: 636.5 kB

Release files / base58_bech32-2026.11.14.tar.gz

Download URL base58_bech32-2026.11.14.tar.gz
Size 603.4 kB
Tags Source
SHA-256 checksum
How to use checksums
246b9ec93b4e3c4305f8e21752a1b68e88b2deaa9895d553180dd0e1abc8970f
BLAKE2b-256 checksum
How to use checksums
a5acc043c103456b414dfc5247e656b1232e72c396883bcf31587cb8e6fb30e9
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 13, 2026.

Transparency log

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

Download URL base58_bech32-2026.11.14-py3-none-any.whl
Size 33.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
352a968c77fc284ec9698fb70c8447294a5c5203a4a756109f1f9a2056360bf0
BLAKE2b-256 checksum
How to use checksums
153677b5795cdde31af4b6461315342e4221a5bdbe61192116c1b7b17b8a1c62
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 13, 2026.

Transparency log

Security for base58-bech32 2026.11.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.

Full provenance

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

Select from 2 files

Attestation for base58_bech32-2026.11.14.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 13, 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