.\" Man page generated from reStructuredText .\" by the Docutils 0.22.3 manpage writer. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "ETH_HASH" "1" "Mar 03, 2026" "0.7" "eth-hash" .SH NAME eth_hash \- eth-hash Documentation .sp The Ethereum hashing function, keccak256, sometimes (erroneously) called sha3 .SH INSTALLATION .INDENT 0.0 .INDENT 3.5 .sp .EX python \-m pip install eth\-hash .EE .UNINDENT .UNINDENT .SS Quickstart .SS Choose a hashing backend .sp If you\(aqre not sure, choose \(dqpycryptodome\(dq because it supports pypy3. .sp You can find a full list of each currently supported backend in \fBeth_hash.backends\fP\&. .SS Install .sp Put the backend you would like to use in brackets during install, like: .INDENT 0.0 .INDENT 3.5 .sp .EX python \-m pip install \(dqeth\-hash[pycryptodome]\(dq .EE .UNINDENT .UNINDENT .SS Compute a Keccak256 Hash .INDENT 0.0 .INDENT 3.5 .sp .EX >>> from eth_hash.auto import keccak >>> keccak(b\(aq\(aq) b\(dq\exc5\exd2F\ex01\ex86\exf7#<\ex92~}\exb2\exdc\exc7\ex03\exc0\exe5\ex00\exb6S\exca\ex82\(aq;{\exfa\exd8\ex04]\ex85\exa4p\(dq .EE .UNINDENT .UNINDENT .sp You may also compute hashes incrementally .INDENT 0.0 .INDENT 3.5 .sp .EX >>> from eth_hash.auto import keccak >>> preimage = keccak.new(b\(aqpart\-a\(aq) >>> preimage.update(b\(aqpart\-b\(aq) >>> preimage.digest() b\(aq6\ex91l\exdd50\exd6[\ex7f\exf9B\exff\exc9SW\ex98\exc3\exaal\exd9\exde\exdd6I\exb7\ex91\ex9e\exf4\(gapl\ex08\(aq .EE .UNINDENT .UNINDENT .sp The preimage object returned may be copied as well. .INDENT 0.0 .INDENT 3.5 .sp .EX >>> from eth_hash.auto import keccak >>> preimage = keccak.new(b\(aqpart\-a\(aq) >>> preimage_copy = preimage.copy() >>> preimage.update(b\(aqpart\-b\(aq) >>> preimage.digest() b\(aq6\ex91l\exdd50\exd6[\ex7f\exf9B\exff\exc9SW\ex98\exc3\exaal\exd9\exde\exdd6I\exb7\ex91\ex9e\exf4\(gapl\ex08\(aq >>> preimage_copy.update(b\(aqpart\-c\(aq) >>> preimage_copy.digest() b\(aq\exffcy45\exea\exdd\exdf\ex8e(\ex1c\exfcF\exf3\exd4\exa1S\ex0f\exdf\exd8\ex01!\exb2(\exe1\exc7\exc6\exa3\ex08\exc3\en\ex0b\(aq .EE .UNINDENT .UNINDENT .SS Select one of many installed backends .sp If you have several backends installed, you may want to explicitly specify which one to load. You can specify in an environment variable, or at runtime. .SS Specify backend by environment variable .INDENT 0.0 .INDENT 3.5 .sp .EX $ ETH_HASH_BACKEND=\(dqpysha3\(dq python >>> from eth_hash.auto import keccak # This runs with the pysha3 backend >>> keccak(b\(aq\(aq) b\(dq\exc5\exd2F\ex01\ex86\exf7#<\ex92~}\exb2\exdc\exc7\ex03\exc0\exe5\ex00\exb6S\exca\ex82\(aq;{\exfa\exd8\ex04]\ex85\exa4p\(dq .EE .UNINDENT .UNINDENT .SS Specify backend at runtime .INDENT 0.0 .INDENT 3.5 .sp .EX >>> from eth_hash.backends import pysha3 >>> from eth_hash import Keccak256 >>> keccak = Keccak256(pysha3) >>> keccak(b\(aq\(aq) b\(dq\exc5\exd2F\ex01\ex86\exf7#<\ex92~}\exb2\exdc\exc7\ex03\exc0\exe5\ex00\exb6S\exca\ex82\(aq;{\exfa\exd8\ex04]\ex85\exa4p\(dq .EE .UNINDENT .UNINDENT .SS eth_hash.backends package .SS Submodules .SS eth_hash.backends.auto module .SS eth_hash.backends.pycryptodome module .SS eth_hash.backends.pysha3 module .SS Module contents .SS eth_hash package .SS eth_hash.auto module .SS eth_hash.main module .SS Release Notes .SS eth\-hash v0.7.1 (2025\-01\-13) .SS Internal Changes \- for eth\-hash Contributors .INDENT 0.0 .IP \(bu 2 Merge template, updating CI runs and what is included in package files (#59 \%) .IP \(bu 2 Run \fBmypy\fP linting locally via a \fBpre\-commit\fP hook (#60 \%) .IP \(bu 2 Merge template updates, notably adding support for \fBpy313\fP and moving docs from the \fBREADME\fP to ReadTheDocs (#61 \%) .UNINDENT .SS eth\-hash v0.7.0 (2024\-03\-01) .SS Internal Changes \- for eth\-hash Contributors .INDENT 0.0 .IP \(bu 2 Merge template updates, notably adding py312 support and testing docs build for all formats (#57 \%) .UNINDENT .SS eth\-hash v0.6.0 (2024\-01\-10) .SS Breaking Changes .INDENT 0.0 .IP \(bu 2 Drop python 3.7 support (#53 \%) .UNINDENT .SS Internal Changes \- for eth\-hash Contributors .INDENT 0.0 .IP \(bu 2 Merge project template updates, notably use \fBpre\-commit\fP for linting and change the name of \fBmaster\fP branch to \fBmain\fP (#53 \%) .IP \(bu 2 Correct booleans in \fBpyproject.toml\fP and add test for presence of \fBeth_hash.__version__\fP attribute (#55 \%) .UNINDENT .SS eth\-hash v0.5.2 (2023\-06\-07) .SS Internal Changes \- for eth\-hash Contributors .INDENT 0.0 .IP \(bu 2 remove unused docs deps, bump version of remaining (#48 \%) .IP \(bu 2 merge updates from the python project template (#51 \%) .UNINDENT .SS eth\-hash v0.5.1 (2022\-11\-09) .SS Features .INDENT 0.0 .IP \(bu 2 Add support for Python 3.11 (#45 \%) .UNINDENT .SS eth\-hash v0.5.0 (2022\-07\-20) .SS Performance improvements .INDENT 0.0 .IP \(bu 2 Prefer pysha3 backend by default (#42 \%) .UNINDENT .SS eth\-hash v0.4.0 (2022\-07\-06) .SS Features .INDENT 0.0 .IP \(bu 2 Add support for Python 3.8, 3.9, 3.10 (#40 \%) .UNINDENT .SS Deprecations and Removals .INDENT 0.0 .IP \(bu 2 Drop support for Python 3.5 and 3.6 (#39 \%) .UNINDENT .SS Miscellaneous changes .INDENT 0.0 .IP \(bu 2 #40 \%, #41 \% .UNINDENT .SS eth\-hash v0.3.3 (2022\-06\-30) .SS Performance improvements .INDENT 0.0 .IP \(bu 2 Keccak backend was initialized every time it was called. Now it\(aqs initialized only the first time it\(aqs called. (#36 \%) .UNINDENT .SS Internal Changes \- for eth\-hash Contributors .INDENT 0.0 .IP \(bu 2 Prune \fBvenv\fP files from the release via MANIFEST.in (#38 \%) .UNINDENT .SS eth\-hash v0.3.2 (2021\-09\-03) .SS Miscellaneous changes .INDENT 0.0 .IP \(bu 2 Drop eth\-utils requirement, to fix dependency cycle (#33 \%) .UNINDENT .SS eth\-hash v0.3.1 (2021\-01\-21) .SS Bugfixes .INDENT 0.0 .IP \(bu 2 Bugfix to export type annotations (#28 \%) .UNINDENT .SS eth\-hash v0.3.0 (2021\-01\-20) .SS Features .INDENT 0.0 .IP \(bu 2 Export type annotations, for use in importing projects (#29 \%) .UNINDENT .SS Internal Changes \- for eth\-hash Contributors .INDENT 0.0 .IP \(bu 2 Import 3 years worth of template updates (#29 \%) .UNINDENT .SS v0.2.0 .sp Released September 5, 2018 .INDENT 0.0 .IP \(bu 2 set \fIpycryptodome\fP version to \fI>=3.6.6,<4\fP to fix a recently discovered vulnerability .UNINDENT .SS v0.1.4 .sp Released May 28, 2018 .INDENT 0.0 .IP \(bu 2 Ensure the auto backend is pickleable (#19) .UNINDENT .SS v0.1.3 .sp Released May 14, 2018 .INDENT 0.0 .IP \(bu 2 The pycryptodome backend now allows \fBupdate()\fP, then \fBdigest()\fP, then \fBupdate()\fP\&. .UNINDENT .SS v0.1.2 .sp Released Apr 2, 2018 .INDENT 0.0 .IP \(bu 2 You can now import eth\-hash without a backend, it won\(aqt fail until trying to generate a hash .UNINDENT .SS v0.1.1 .sp Released Mar 15, 2018 .INDENT 0.0 .IP \(bu 2 upgrade pycryptodome to v3.5.1+ .IP \(bu 2 performance improvements with preimage .IP \(bu 2 Better docs and tests .UNINDENT .SS v0.1.0 .sp Released Feb 28, 2018 .INDENT 0.0 .IP \(bu 2 Add support for \fBbytearray\fP \% input to keccak .IP \(bu 2 Add support for incrementally building hash results .UNINDENT .SS v0.1.0\-alpha.3 .sp Released Feb 7, 2018 .INDENT 0.0 .IP \(bu 2 Add pycryptodome backend support .IP \(bu 2 Add pysha3 backend support .IP \(bu 2 Can specify backend in environment variable \fBETH_HASH_BACKEND\fP .IP \(bu 2 New Quickstart \%<#\:quickstart> docs .UNINDENT .SS v0.1.0\-alpha.2 .sp Released Feb 6, 2018 .INDENT 0.0 .IP \(bu 2 Bugfix pypy3 reference in pypi .UNINDENT .SS v0.1.0\-alpha.1 .INDENT 0.0 .IP \(bu 2 Launched repository, claimed names for pip, RTD, github, etc .UNINDENT .SS Contributing .sp Thank you for your interest in contributing! We welcome all contributions no matter their size. Please read along to learn how to get started. If you get stuck, feel free to ask for help in Ethereum Python Discord server \%\&. .SS Setting the stage .sp To get started, fork the repository to your own github account, then clone it to your development machine: .INDENT 0.0 .INDENT 3.5 .sp .EX git clone git@github.com:your\-github\-username/eth\-hash.git .EE .UNINDENT .UNINDENT .sp Next, install the development dependencies. We recommend using a virtual environment, such as virtualenv \%\&. .INDENT 0.0 .INDENT 3.5 .sp .EX cd eth\-hash virtualenv \-p python venv \&. venv/bin/activate python \-m pip install \-e \(dq.[dev]\(dq pre\-commit install .EE .UNINDENT .UNINDENT .SS Running the tests .sp A great way to explore the code base is to run the tests. .sp We can run all tests with: .INDENT 0.0 .INDENT 3.5 .sp .EX pytest tests .EE .UNINDENT .UNINDENT .SS Code Style .sp We use pre\-commit \% to enforce a consistent code style across the library. This tool runs automatically with every commit, but you can also run it manually with: .INDENT 0.0 .INDENT 3.5 .sp .EX make lint .EE .UNINDENT .UNINDENT .sp If you need to make a commit that skips the \fBpre\-commit\fP checks, you can do so with \fBgit commit \-\-no\-verify\fP\&. .sp This library uses type hints, which are enforced by the \fBmypy\fP tool (part of the \fBpre\-commit\fP checks). All new code is required to land with type hints, with the exception of code within the \fBtests\fP directory. .SS Documentation .sp Good documentation will lead to quicker adoption and happier users. Please check out our guide on how to create documentation for the Python Ethereum ecosystem \%\&. .SS Pull Requests .sp It\(aqs a good idea to make pull requests early on. A pull request represents the start of a discussion, and doesn\(aqt necessarily need to be the final, finished submission. .sp GitHub\(aqs documentation for working on pull requests is available here \%\&. .sp Once you\(aqve made a pull request, take a look at the Circle CI build status in the GitHub interface and make sure all tests are passing. In general pull requests that do not pass the CI build yet won\(aqt get reviewed unless explicitly requested. .sp If the pull request introduces changes that should be reflected in the release notes, please add a \fInewsfragment\fP file as explained here \%\&. .sp If possible, the change to the release notes file should be included in the commit that introduces the feature or bugfix. .SS Releasing .sp Releases are typically done from the \fBmain\fP branch, except when releasing a beta (in which case the beta is released from \fBmain\fP, and the previous stable branch is released from said branch). .SS Final test before each release .sp Before releasing a new version, build and test the package that will be released: .INDENT 0.0 .INDENT 3.5 .sp .EX git checkout main && git pull make package\-test .EE .UNINDENT .UNINDENT .sp This will build the package and install it in a temporary virtual environment. Follow the instructions to activate the venv and test whatever you think is important. .sp You can also preview the release notes: .INDENT 0.0 .INDENT 3.5 .sp .EX towncrier \-\-draft .EE .UNINDENT .UNINDENT .SS Build the release notes .sp Before bumping the version number, build the release notes. You must include the part of the version to bump (see below), which changes how the version number will show in the release notes. .INDENT 0.0 .INDENT 3.5 .sp .EX make notes bump=$$VERSION_PART_TO_BUMP$$ .EE .UNINDENT .UNINDENT .sp If there are any errors, be sure to re\-run make notes until it works. .SS Push the release to github & pypi .sp After confirming that the release package looks okay, release a new version: .INDENT 0.0 .INDENT 3.5 .sp .EX make release bump=$$VERSION_PART_TO_BUMP$$ .EE .UNINDENT .UNINDENT .sp This command will: .INDENT 0.0 .IP \(bu 2 Bump the version number as specified in \fB\&.pyproject.toml\fP and \fBsetup.py\fP\&. .IP \(bu 2 Create a git commit and tag for the new version. .IP \(bu 2 Build the package. .IP \(bu 2 Push the commit and tag to github. .IP \(bu 2 Push the new package files to pypi. .UNINDENT .SS Which version part to bump .sp \fB$$VERSION_PART_TO_BUMP$$\fP must be one of: \fBmajor\fP, \fBminor\fP, \fBpatch\fP, \fBstage\fP, or \fBdevnum\fP\&. .sp The version format for this repo is \fB{major}.{minor}.{patch}\fP for stable, and \fB{major}.{minor}.{patch}\-{stage}.{devnum}\fP for unstable (\fBstage\fP can be alpha or beta). .sp If you are in a beta version, \fBmake release bump=stage\fP will switch to a stable. .sp To issue an unstable version when the current version is stable, specify the new version explicitly, like \fBmake release bump=\(dq\-\-new\-version 4.0.0\-alpha.1\(dq\fP .sp You can see what the result of bumping any particular version part would be with \fBbump\-my\-version show\-bump\fP .SS Code of Conduct .SS Our Pledge .sp In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment\-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, education, socio\-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. .SS Our Standards .sp Examples of behavior that contributes to creating a positive environment include: .INDENT 0.0 .IP \(bu 2 Using welcoming and inclusive language .IP \(bu 2 Being respectful of differing viewpoints and experiences .IP \(bu 2 Gracefully accepting constructive criticism .IP \(bu 2 Focusing on what is best for the community .IP \(bu 2 Showing empathy towards other community members .UNINDENT .sp Examples of unacceptable behavior by participants include: .INDENT 0.0 .IP \(bu 2 The use of sexualized language or imagery and unwelcome sexual attention or advances .IP \(bu 2 Trolling, insulting/derogatory comments, and personal or political attacks .IP \(bu 2 Public or private harassment .IP \(bu 2 Publishing others\(aq private information, such as a physical or electronic address, without explicit permission .IP \(bu 2 Other conduct which could reasonably be considered inappropriate in a professional setting .UNINDENT .SS Our Responsibilities .sp Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. .sp Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. .SS Scope .sp This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e\-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. .SS Enforcement .sp Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at \%\&. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. .sp Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project\(aqs leadership. .SS Attribution .sp This Code of Conduct is adapted from the Contributor Covenant \%, version 1.4, available at \% .SH INDICES AND TABLES .INDENT 0.0 .IP \(bu 2 Index \%<> .IP \(bu 2 Module Index \%<> .UNINDENT .SH Author The Ethereum Foundation .SH Copyright 2018-2023, The Ethereum Foundation .\" End of generated man page.