{"id":24366,"library":"pymultihash","title":"pymultihash","description":"Python implementation of the multihash specification (current version 0.8.2). Multihash is a self-describing hash format that includes a hash function identifier and digest length. This library provides encoding, decoding, and hashing utilities. Release cadence is low; last release was in 2020.","status":"active","version":"0.8.2","language":"python","source_language":"en","source_url":"https://github.com/ivilata/pymultihash","tags":["multihash","hashing","ipfs","self-describing"],"install":[{"cmd":"pip install pymultihash","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"The package provides a top-level module `multihash`, not a submodule under `pymultihash`.","wrong":"from pymultihash import multihash","symbol":"multihash","correct":"import multihash"}],"quickstart":{"code":"import multihash\n\n# Hash data using SHA2-256 (code 0x12)\ndigest = multihash.digest(b'hello world', 'sha2-256')\nprint(digest.hex())  # multihash encoded\n\n# Decode a multihash\ndecoded = multihash.decode(digest)\nprint(decoded.code)  # 0x12\nprint(decoded.digest.hex())  # raw digest\n\n# Hash with a specific length (truncated)\ndigest_trunc = multihash.digest(b'hello world', 'sha2-256', 8)\nprint(len(digest_trunc))  # 1 (varint code) + 1 (length) + 8 = 10 bytes","lang":"python","description":"Encode and decode multihashes using the standard functions."},"warnings":[{"fix":"Use `multihash.decode()` to extract the raw digest, or use `hashlib` for raw hashing and then `multihash.encode()` to wrap it.","message":"The `digest` function returns a multihash-encoded byte string (with code and length prefix), not a raw hash digest. This differs from other multihash libraries.","severity":"gotcha","affected_versions":"all"},{"fix":"Use the exact names as defined in the multihash table: 'sha1', 'sha2-256', 'sha2-512', 'sha3-512', 'blake2b-256', etc.","message":"Hash function names are lowercase with hyphens (e.g., 'sha2-256', 'sha3-512'). Using incorrect casing (e.g., 'SHA256') raises a ValueError.","severity":"gotcha","affected_versions":"all"},{"fix":"Monitor the repo for API changes; no breaking changes have occurred yet.","message":"The `encode` and `decode` functions may be renamed or deprecated in future versions. Check the latest documentation.","severity":"deprecated","affected_versions":"0.8.x"}],"env_vars":null,"search_vec":"'0.8.2':10 '2020':44 'cadenc':37 'current':8 'decod':32 'describ':16,50 'digest':26 'encod':31 'format':18 'function':23 'hash':17,22,34,46 'identifi':24 'implement':3 'includ':20 'ipf':47 'last':40 'length':27 'librari':29 'low':39 'multihash':6,11,45 'provid':30 'pymultihash':1 'python':2 'releas':36,41 'self':15,49 'self-describ':14,48 'specif':7 'util':35 'version':9","created_at":"2026-05-01T08:12:41.846055+00:00","updated_at":"2026-05-01T08:12:41.846055+00:00","problems":[{"fix":"Ensure the input to `decode()` is a complete multihash-encoded byte string, not a raw hash. Use `digest()` to create a valid multihash.","cause":"Passing a raw digest (without the multihash code+length prefix) to `decode()`.","error":"ValueError: Unknown multihash code: 0x12"},{"fix":"Use `import multihash` (the package exposes a top-level module).","cause":"Using incorrect import path (e.g., `from pymultihash import multihash`).","error":"NameError: name 'multihash' is not defined"},{"fix":"Use the full multihash name: 'sha2-256', 'sha2-512', 'sha3-512', etc.","cause":"Using an incorrect hash function name (common mistake: using 'sha256' instead of 'sha2-256').","error":"ValueError: Unsupported hash function: sha256"},{"fix":"Use `multihash.digest(data, 'sha2-256', length=16)` instead of positional third argument.","cause":"The third argument `length` is optional but must be passed as a keyword argument if provided.","error":"TypeError: digest() takes 2 positional arguments but 3 were given"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.8.2","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/ivilata/pymultihash","docs":null,"changelog":null,"pypi":"https://pypi.org/project/pymultihash/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-29","last_verified":"2026-06-29","next_check":"2026-07-29","install_tag":null}}