{"id":15356695,"url":"https://github.com/filips123/contenthashpy","last_synced_at":"2026-03-15T05:02:24.228Z","repository":{"id":62564628,"uuid":"198833263","full_name":"filips123/ContentHashPy","owner":"filips123","description":"Python implementation of EIP 1577 content hash","archived":false,"fork":false,"pushed_at":"2023-12-24T16:55:44.000Z","size":31,"stargazers_count":16,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T06:42:01.434Z","etag":null,"topics":["decentralized","eip1577","ens","ethereum","ethereum-name-service","python","web3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/filips123.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"filips123","patreon":"filips","ko_fi":"filips","liberapay":"filips","custom":["https://donorbox.org/filips","https://buymeacoff.ee/filips"]}},"created_at":"2019-07-25T13:06:36.000Z","updated_at":"2024-07-10T17:14:24.000Z","dependencies_parsed_at":"2023-12-24T14:27:53.188Z","dependency_job_id":"2be175b6-568c-459a-9adc-8030d4f36346","html_url":"https://github.com/filips123/ContentHashPy","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filips123%2FContentHashPy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filips123%2FContentHashPy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filips123%2FContentHashPy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filips123%2FContentHashPy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/filips123","download_url":"https://codeload.github.com/filips123/ContentHashPy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249023725,"owners_count":21199958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["decentralized","eip1577","ens","ethereum","ethereum-name-service","python","web3"],"created_at":"2024-10-01T12:29:38.230Z","updated_at":"2026-03-15T05:02:19.176Z","avatar_url":"https://github.com/filips123.png","language":"Python","funding_links":["https://github.com/sponsors/filips123","https://patreon.com/filips","https://ko-fi.com/filips","https://liberapay.com/filips","https://donorbox.org/filips","https://buymeacoff.ee/filips"],"categories":[],"sub_categories":[],"readme":"ContentHash for Python\n======================\n\n[![version][icon-version]][link-pypi]\n[![downloads][icon-downloads]][link-pypi]\n[![license][icon-license]][link-license]\n[![python][icon-python]][link-python]\n\n[![build][icon-build]][link-build]\n[![coverage][icon-coverage]][link-coverage]\n[![quality][icon-quality]][link-quality]\n\nPython implementation of EIP 1577 content hash.\n\n## Description\n\nThis is a simple package made for encoding and decoding content hashes has specified in the [EIP 1577][link-eip-1577].\nThis package will be useful for every [Ethereum][link-ethereum] developer wanting to interact with [EIP 1577][link-eip-1577] compliant [ENS resolvers][link-resolvers].\n\nFor JavaScript implementation, see [`pldespaigne/content-hash`][link-javascript-implementation].\n\n## Installation\n\n### Requirements\n\nContentHash requires Python 3.8 or higher.\n\n### From PyPI\n\nThe recommended way to install ContentHash is from PyPI with PIP.\n\n```bash\npip install content-hash\n```\n\n### From Source\n\nAlternatively, you can also install it from the source.\n\n```bash\ngit clone https://github.com/filips123/ContentHashPy.git\ncd ContentHashPy\npip install .\n```\n\n## Usage\n\n### Supported Codecs\n\nThe following codecs are currently supported:\n\n- `swarm`\n- `ipfs`\n- `ipns`\n\nEvery other codec supported by [`multicodec`][link-multicodec] will be encoded by default in `utf-8`. You can see the full list of the supported codecs [here][link-supported-codecs].\n\n### Getting Codec\n\nYou can use a `get_codec` function to get codec from the content hash.\n\nIt takes a content hash as a HEX string and returns the codec name. A content hash can be prefixed with a `0x`, but it's not mandatory.\n\n```py\nimport content_hash\n\nchash = 'bc037a716b746c776934666563766f367269'\ncodec = content_hash.get_codec(chash)\n\nprint(codec) # onion\n```\n\n### Decoding\n\nYou can use a `decode` function to decode a content hash.\n\nIt takes a content hash as a HEX string and returns the decoded content as a string. A content hash can be prefixed with a `0x`, but it's not mandatory.\n\n```py\nimport content_hash\n\nchash = 'e3010170122029f2d17be6139079dc48696d1f582a8530eb9805b561eda517e22a892c7e3f1f'\nvalue = content_hash.decode(chash)\n\nprint(value) # QmRAQB6YaCyidP37UdDnjFY5vQuiBrcqdyoW1CuDgwxkD4\n```\n\n### Encoding\n\nYou can use an `encode` function to encode a content hash.\n\nIt takes a supported codec as a string and a value as a string and returns the corresponding content hash as a HEX string. The output will not be prefixed with a `0x`.\n\n```py\nimport content_hash\n\ncodec = 'swarm-ns'\nvalue = 'd1de9994b4d039f6548d191eb26786769f580809256b4685ef316805265ea162'\nchash = content_hash.encode(codec, value)\n\nprint(chash) # e40101701b20d1de9994b4d039f6548d191eb26786769f580809256b4685ef316805265ea162\n```\n\n## Creating Codecs\n\nAll supported codec profiles are available in [`content_hash/profiles/__init__.py`][link-profiles-file], in `PROFILES` dictionary. You need to add a new profile there. You only need to add a new profile if your codec encoding and decoding are different from `utf-8`.\n\nEach profile must have the same name as the corresponding codec in the `multicodec` library.\n\nA profile must also have decode and encode function. They should be passed as a string containing the name of the module for required decode or encode. All such modules are available in [`content_hash/decodes`][link-decodes-directory] and [`content_hash/encodes`][link-encodes-directory].\n\nEach module name should describe it as much as possible. Its name can only contain valid characters for Python modules.\n\nEach decode module must have a `decode` function. It must be a function that takes a `bytes` input and returns a `str` result.\n\nEach encode module must have an `encode` function. It must be a function that takes a `str` input and returns a `bytes` result.\n\nAll inputs and outputs must be the same as in the [JavaScript implementation][link-javascript-implementation]. Multiple profiles can share the same decodes and encodes.\n\n## Versioning\n\nThis library uses [SemVer][link-semver] for versioning. For the versions available, see [the tags][link-tags] on this repository.\n\n## License\n\nThis library is licensed under the MIT license. See the [LICENSE][link-license-file] file for details.\n\n[icon-version]: https://img.shields.io/pypi/v/content-hash.svg?style=flat-square\u0026label=version\n[icon-downloads]: https://img.shields.io/pypi/dm/content-hash.svg?style=flat-square\u0026label=downloads\n[icon-license]: https://img.shields.io/pypi/l/content-hash.svg?style=flat-square\u0026label=license\n[icon-python]: https://img.shields.io/pypi/pyversions/content-hash?style=flat-square\u0026label=python\n\n[icon-build]: https://img.shields.io/github/actions/workflow/status/filips123/ContentHashPy/main.yml?style=flat-square\u0026label=build\n[icon-coverage]: https://img.shields.io/scrutinizer/coverage/g/filips123/ContentHashPy.svg?style=flat-square\u0026label=coverage\n[icon-quality]: https://img.shields.io/scrutinizer/g/filips123/ContentHashPy.svg?style=flat-square\u0026label=quality\n\n[link-pypi]: https://pypi.org/project/content-hash/\n[link-license]: https://choosealicense.com/licenses/mit/\n[link-python]: https://python.org/\n[link-build]: https://github.com/filips123/ContentHashPy/actions\n[link-coverage]: https://scrutinizer-ci.com/g/filips123/ContentHashPy/code-structure/\n[link-quality]: https://scrutinizer-ci.com/g/filips123/ContentHashPy/\n[link-semver]: https://semver.org/\n\n[link-eip-1577]: https://github.com/ethereum/ercs/blob/master/ERCS/erc-1577.md\n[link-ethereum]: https://www.ethereum.org/\n[link-resolvers]: http://docs.ens.domains/en/latest/introduction.html\n[link-multicodec]: https://github.com/multiformats/multicodec/\n[link-supported-codecs]: https://github.com/multiformats/multicodec/blob/master/table.csv\n\n[link-tags]: https://github.com/filips123/ContentHashPy/tags/\n[link-license-file]: https://github.com/filips123/ContentHashPy/blob/master/LICENSE\n[link-profiles-file]: https://github.com/filips123/ContentHashPy/blob/master/content_hash/profiles/__init__.py\n[link-decodes-directory]: https://github.com/filips123/ContentHashPy/tree/master/content_hash/decodes/\n[link-encodes-directory]: https://github.com/filips123/ContentHashPy/tree/master/content_hash/encodes/\n\n[link-javascript-implementation]: https://github.com/pldespaigne/content-hash/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffilips123%2Fcontenthashpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffilips123%2Fcontenthashpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffilips123%2Fcontenthashpy/lists"}