hexbytes


Namehexbytes JSON
Version 1.2.1 PyPI version JSON
download
home_pagehttps://github.com/ethereum/hexbytes
Summaryhexbytes: Python `bytes` subclass that decodes hex, with a readable console output
upload_time2024-06-17 18:49:49
maintainerNone
docs_urlNone
authorThe Ethereum Foundation
requires_python<4,>=3.8
licenseMIT
keywords ethereum
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # HexBytes

[![Join the conversation on Discord](https://img.shields.io/discord/809793915578089484?color=blue&label=chat&logo=discord&logoColor=white)](https://discord.gg/GHryRvPB84)
[![Build Status](https://circleci.com/gh/ethereum/hexbytes.svg?style=shield)](https://circleci.com/gh/ethereum/hexbytes)
[![PyPI version](https://badge.fury.io/py/hexbytes.svg)](https://badge.fury.io/py/hexbytes)
[![Python versions](https://img.shields.io/pypi/pyversions/hexbytes.svg)](https://pypi.python.org/pypi/hexbytes)
[![Docs build](https://readthedocs.org/projects/hexbytes/badge/?version=latest)](https://hexbytes.readthedocs.io/en/latest/?badge=latest)

Python `bytes` subclass that decodes hex, with a readable console output

Read the [documentation](https://hexbytes.readthedocs.io/).

View the [change log](https://hexbytes.readthedocs.io/en/latest/release_notes.html).

## Quickstart

```sh
python -m pip install hexbytes
```

```py
# convert from bytes to a prettier representation at the console
>>> HexBytes(b"\x03\x08wf\xbfh\xe7\x86q\xd1\xeaCj\xe0\x87\xdat\xa1'a\xda\xc0 \x01\x1a\x9e\xdd\xc4\x90\x0b\xf1;")
HexBytes('0x03087766bf68e78671d1ea436ae087da74a12761dac020011a9eddc4900bf13b')

# HexBytes accepts the hex string representation as well, ignoring case and 0x prefixes
>>> hb = HexBytes('03087766BF68E78671D1EA436AE087DA74A12761DAC020011A9EDDC4900BF13B')
HexBytes('0x03087766bf68e78671d1ea436ae087da74a12761dac020011a9eddc4900bf13b')

# get the first byte:
>>> hb[0]
3

# show how many bytes are in the value
>>> len(hb)
32

# cast back to the basic `bytes` type
>>> bytes(hb)
b"\x03\x08wf\xbfh\xe7\x86q\xd1\xeaCj\xe0\x87\xdat\xa1'a\xda\xc0 \x01\x1a\x9e\xdd\xc4\x90\x0b\xf1;"
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ethereum/hexbytes",
    "name": "hexbytes",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.8",
    "maintainer_email": null,
    "keywords": "ethereum",
    "author": "The Ethereum Foundation",
    "author_email": "snakecharmers@ethereum.org",
    "download_url": "https://files.pythonhosted.org/packages/4e/51/06836a542b773bfc60ab871fa08d4a7963e7df6754ca57169e2654287cc1/hexbytes-1.2.1.tar.gz",
    "platform": null,
    "description": "# HexBytes\n\n[![Join the conversation on Discord](https://img.shields.io/discord/809793915578089484?color=blue&label=chat&logo=discord&logoColor=white)](https://discord.gg/GHryRvPB84)\n[![Build Status](https://circleci.com/gh/ethereum/hexbytes.svg?style=shield)](https://circleci.com/gh/ethereum/hexbytes)\n[![PyPI version](https://badge.fury.io/py/hexbytes.svg)](https://badge.fury.io/py/hexbytes)\n[![Python versions](https://img.shields.io/pypi/pyversions/hexbytes.svg)](https://pypi.python.org/pypi/hexbytes)\n[![Docs build](https://readthedocs.org/projects/hexbytes/badge/?version=latest)](https://hexbytes.readthedocs.io/en/latest/?badge=latest)\n\nPython `bytes` subclass that decodes hex, with a readable console output\n\nRead the [documentation](https://hexbytes.readthedocs.io/).\n\nView the [change log](https://hexbytes.readthedocs.io/en/latest/release_notes.html).\n\n## Quickstart\n\n```sh\npython -m pip install hexbytes\n```\n\n```py\n# convert from bytes to a prettier representation at the console\n>>> HexBytes(b\"\\x03\\x08wf\\xbfh\\xe7\\x86q\\xd1\\xeaCj\\xe0\\x87\\xdat\\xa1'a\\xda\\xc0 \\x01\\x1a\\x9e\\xdd\\xc4\\x90\\x0b\\xf1;\")\nHexBytes('0x03087766bf68e78671d1ea436ae087da74a12761dac020011a9eddc4900bf13b')\n\n# HexBytes accepts the hex string representation as well, ignoring case and 0x prefixes\n>>> hb = HexBytes('03087766BF68E78671D1EA436AE087DA74A12761DAC020011A9EDDC4900BF13B')\nHexBytes('0x03087766bf68e78671d1ea436ae087da74a12761dac020011a9eddc4900bf13b')\n\n# get the first byte:\n>>> hb[0]\n3\n\n# show how many bytes are in the value\n>>> len(hb)\n32\n\n# cast back to the basic `bytes` type\n>>> bytes(hb)\nb\"\\x03\\x08wf\\xbfh\\xe7\\x86q\\xd1\\xeaCj\\xe0\\x87\\xdat\\xa1'a\\xda\\xc0 \\x01\\x1a\\x9e\\xdd\\xc4\\x90\\x0b\\xf1;\"\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "hexbytes: Python `bytes` subclass that decodes hex, with a readable console output",
    "version": "1.2.1",
    "project_urls": {
        "Homepage": "https://github.com/ethereum/hexbytes"
    },
    "split_keywords": [
        "ethereum"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "39c620f25ea73e4ceffb3eb4e38347f2992cb25e5ff6eb644d52e753a7a72f57",
                "md5": "6d956758dfb4d48b3893a990add76a40",
                "sha256": "e64890b203a31f4a23ef11470ecfcca565beaee9198df623047df322b757471a"
            },
            "downloads": -1,
            "filename": "hexbytes-1.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6d956758dfb4d48b3893a990add76a40",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.8",
            "size": 5160,
            "upload_time": "2024-06-17T18:49:43",
            "upload_time_iso_8601": "2024-06-17T18:49:43.364734Z",
            "url": "https://files.pythonhosted.org/packages/39/c6/20f25ea73e4ceffb3eb4e38347f2992cb25e5ff6eb644d52e753a7a72f57/hexbytes-1.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4e5106836a542b773bfc60ab871fa08d4a7963e7df6754ca57169e2654287cc1",
                "md5": "d5967c20e8cc87b6bc43ab5fab20d486",
                "sha256": "515f00dddf31053db4d0d7636dd16061c1d896c3109b8e751005db4ca46bcca7"
            },
            "downloads": -1,
            "filename": "hexbytes-1.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "d5967c20e8cc87b6bc43ab5fab20d486",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.8",
            "size": 7722,
            "upload_time": "2024-06-17T18:49:49",
            "upload_time_iso_8601": "2024-06-17T18:49:49.716121Z",
            "url": "https://files.pythonhosted.org/packages/4e/51/06836a542b773bfc60ab871fa08d4a7963e7df6754ca57169e2654287cc1/hexbytes-1.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-17 18:49:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ethereum",
    "github_project": "hexbytes",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "circle": true,
    "tox": true,
    "lcname": "hexbytes"
}
        
Elapsed time: 0.29931s