{"id":9547,"library":"base58check","title":"Base58check","description":"This library provides functions for Base58check encoding and decoding of binary data, commonly used in cryptocurrencies like Bitcoin. It is currently at version 1.0.2 and maintains a stable, low-cadence release cycle.","status":"active","version":"1.0.2","language":"en","source_language":"en","source_url":"https://github.com/joeblackwaslike/base58check","tags":["encoding","base58","base58check","cryptocurrency","bitcoin","blockchain"],"install":[{"cmd":"pip install base58check","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"The functions are named `b58encode` and `b58decode` within the module.","wrong":"from base58check import encode","symbol":"b58encode","correct":"import base58check\nencoded_data = base58check.b58encode(b'my_data')"},{"note":"The functions are named `b58encode` and `b58decode` within the module.","wrong":"from base58check import decode","symbol":"b58decode","correct":"import base58check\ndecoded_data = base58check.b58decode('encodedstring')"}],"quickstart":{"code":"import base58check\n\n# Encode binary data\noriginal_data = b\"Hello, Base58Check!\"\nencoded_string = base58check.b58encode(original_data)\nprint(f\"Encoded: {encoded_string}\")\n\n# Decode a Base58Check string\ndecoded_data = base58check.b58decode(encoded_string)\nprint(f\"Decoded: {decoded_data}\")\n\n# Example with a Bitcoin-like address (simulated for demonstration)\nsimulated_address_bytes = b'\\x00' + b'\\x01\\x09\\x66\\x77\\x60\\x06\\x95\\x3D\\x55\\x67\\x43\\x9E\\x5E\\x39\\x8E\\x8B\\x0D\\x9C\\x1C\\x00\\x10' # Example payload\nsimulated_address_encoded = base58check.b58encode(simulated_address_bytes)\nprint(f\"Simulated Address: {simulated_address_encoded}\")\n","lang":"python","description":"Demonstrates encoding a byte string and decoding it back, along with a simple example of a Bitcoin-like address encoding pattern."},"warnings":[{"fix":"Always use this library when a Base58Check checksum is required. If plain Base58 is needed, use a different library (e.g., `base58`).","message":"The library implements Base58Check encoding/decoding, which includes a checksum. It does not provide plain Base58 encoding without the checksum. Ensure your application requires the checksum for security and integrity.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Wrap decoding calls in a `try...except ValueError` block to manage invalid input strings. For example: `try: data = base58check.b58decode(s) except ValueError: print('Invalid string')`.","message":"When decoding, an invalid Base58Check string (e.g., incorrect characters, wrong length, or a failed checksum) will raise a `ValueError`. It's essential to handle these exceptions gracefully.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your input for `b58encode` is a `bytes` object (e.g., `b'my_data'`) for clarity and to prevent unexpected behavior with non-ASCII characters if not explicitly handled.","message":"The `b58encode` function accepts either a string or bytes. While it converts strings to bytes internally using UTF-8, it is generally best practice to explicitly provide `bytes` for binary data encoding to avoid potential encoding issues.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Ensure the input string was originally encoded using Base58Check and is not corrupted. Implement `try...except ValueError` for robust error handling.","cause":"Attempting to decode a string that is not a valid Base58Check format (e.g., incorrect characters, wrong length, or a failed checksum verification).","error":"ValueError: Invalid base58check string"},{"fix":"Correct the function call to `base58check.b58encode()` for encoding and `base58check.b58decode()` for decoding.","cause":"Trying to use `base58check.encode()` or `base58check.decode()` directly instead of the library's specific function names `base58check.b58encode()` and `base58check.b58decode()`.","error":"AttributeError: module 'base58check' has no attribute 'encode'"}]}