{ "info": { "author": "Filip \u0160", "author_email": "projects@filips.si", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Topic :: Internet :: Name Service (DNS)", "Topic :: Scientific/Engineering :: Interface Engine/Protocol Translator", "Topic :: Security :: Cryptography", "Topic :: Software Development :: Libraries", "Topic :: Utilities" ], "description": "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[![linux build][icon-travis]][link-travis]\n[![windows build][icon-appveyor]][link-appveyor]\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.5 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\npython setup.py install\n```\n\n## Usage\n\n### Supported Codecs\n\nThe following codecs are currently supported:\n\n- `swarm-ns`\n- `ipfs-ns`\n- `ipns-ns`\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&label=version\n[icon-downloads]: https://img.shields.io/pypi/dm/content-hash.svg?style=flat-square&label=downloads\n[icon-license]: https://img.shields.io/pypi/l/content-hash.svg?style=flat-square&label=license\n[icon-python]: https://img.shields.io/pypi/pyversions/content-hash?style=flat-square&label=python\n\n[icon-travis]: https://img.shields.io/travis/com/filips123/ContentHashPy.svg?style=flat-square&label=linux+build\n[icon-appveyor]: https://img.shields.io/appveyor/ci/filips123/ContentHashPy.svg?style=flat-square&label=windows+build\n[icon-coverage]: https://img.shields.io/scrutinizer/coverage/g/filips123/ContentHashPy.svg?style=flat-square&label=coverage\n[icon-quality]: https://img.shields.io/scrutinizer/g/filips123/ContentHashPy.svg?style=flat-square&label=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-travis]: https://travis-ci.com/filips123/ContentHashPy/\n[link-appveyor]: https://ci.appveyor.com/project/filips123/ContentHashPy/\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/EIPs/blob/master/EIPS/eip-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\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/filips123/ContentHashPy/", "keywords": "ethereum,ethereum-name-service,ens,eip1577,web3,decentralized", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "content-hash", "package_url": "https://pypi.org/project/content-hash/", "platform": "", "project_url": "https://pypi.org/project/content-hash/", "project_urls": { "Homepage": "https://github.com/filips123/ContentHashPy/" }, "release_url": "https://pypi.org/project/content-hash/1.1.0/", "requires_dist": [ "py-cid (<0.4.0,>=0.3.0)", "py-multicodec (<0.3.0,>=0.2.1)", "py-multihash (<0.3.0,>=0.2.3)", "pylint ; extra == 'lint'", "pytest ; extra == 'test'", "pytest-cov ; extra == 'test'" ], "requires_python": ">= 3.5", "summary": "Python implementation of EIP 1577 content hash", "version": "1.1.0" }, "last_serial": 5908334, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "49e14c4912e619c4902ca2e14e5981ab", "sha256": "fa323948276e09e1d81544a9480e4e962a6e19ddab2cca19fec5ac0aac22e235" }, "downloads": -1, "filename": "content_hash-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "49e14c4912e619c4902ca2e14e5981ab", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">= 3.5", "size": 18048, "upload_time": "2019-08-04T17:40:15", "url": "https://files.pythonhosted.org/packages/d2/b2/ef815a6149ddad0264df1c9aefb6b7a4d16ef6d6c3355f68820d3d603af9/content_hash-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e1a0022c69ab1a5b47be93981bc03518", "sha256": "2be108f39ddbcfc79868cd84c7aeee4e7347a40d11c6191897c5b67753386704" }, "downloads": -1, "filename": "content-hash-1.0.0.tar.gz", "has_sig": false, "md5_digest": "e1a0022c69ab1a5b47be93981bc03518", "packagetype": "sdist", "python_version": "source", "requires_python": ">= 3.5", "size": 12664, "upload_time": "2019-08-04T17:40:17", "url": "https://files.pythonhosted.org/packages/b8/42/e83d0c604cfbfd9ce3a87ed0e931e4c8c5509260d39412274f15ebe0a02d/content-hash-1.0.0.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "b4c19f0c0ef2ef9ad43efa29f1d06ef2", "sha256": "b9b027aa6e8ee28c14443ca4ec5eb644e0823feaa7ce4e3f421d3517c0141844" }, "downloads": -1, "filename": "content_hash-1.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "b4c19f0c0ef2ef9ad43efa29f1d06ef2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">= 3.5", "size": 18194, "upload_time": "2019-09-30T18:25:23", "url": "https://files.pythonhosted.org/packages/34/99/ed315e8443e1e42bf5f4edf1392b590ba902536304180a28494b2fae85d8/content_hash-1.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "72df31abb1b8fd0652a6826f6491fa49", "sha256": "6f2fce2c0ca995d40ba68fb33a31a8969a0f8c42410f3ca3bc055a6512713686" }, "downloads": -1, "filename": "content-hash-1.1.0.tar.gz", "has_sig": false, "md5_digest": "72df31abb1b8fd0652a6826f6491fa49", "packagetype": "sdist", "python_version": "source", "requires_python": ">= 3.5", "size": 12983, "upload_time": "2019-09-30T18:25:25", "url": "https://files.pythonhosted.org/packages/b2/97/f8e208effa19b634ffdf7faee7b03d384119180afa4e99e7f72f5ebb3102/content-hash-1.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b4c19f0c0ef2ef9ad43efa29f1d06ef2", "sha256": "b9b027aa6e8ee28c14443ca4ec5eb644e0823feaa7ce4e3f421d3517c0141844" }, "downloads": -1, "filename": "content_hash-1.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "b4c19f0c0ef2ef9ad43efa29f1d06ef2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">= 3.5", "size": 18194, "upload_time": "2019-09-30T18:25:23", "url": "https://files.pythonhosted.org/packages/34/99/ed315e8443e1e42bf5f4edf1392b590ba902536304180a28494b2fae85d8/content_hash-1.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "72df31abb1b8fd0652a6826f6491fa49", "sha256": "6f2fce2c0ca995d40ba68fb33a31a8969a0f8c42410f3ca3bc055a6512713686" }, "downloads": -1, "filename": "content-hash-1.1.0.tar.gz", "has_sig": false, "md5_digest": "72df31abb1b8fd0652a6826f6491fa49", "packagetype": "sdist", "python_version": "source", "requires_python": ">= 3.5", "size": 12983, "upload_time": "2019-09-30T18:25:25", "url": "https://files.pythonhosted.org/packages/b2/97/f8e208effa19b634ffdf7faee7b03d384119180afa4e99e7f72f5ebb3102/content-hash-1.1.0.tar.gz" } ] }