py-multihash 2.0.0__tar.gz → 3.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- py_multihash-3.0.0/CONTRIBUTING.rst +191 -0
- py_multihash-3.0.0/HISTORY.rst +44 -0
- {py-multihash-2.0.0 → py_multihash-3.0.0}/LICENSE +0 -1
- py_multihash-3.0.0/PKG-INFO +107 -0
- py_multihash-3.0.0/README.rst +62 -0
- {py-multihash-2.0.0 → py_multihash-3.0.0}/docs/api_reference.rst +12 -0
- {py-multihash-2.0.0 → py_multihash-3.0.0}/docs/conf.py +13 -4
- {py-multihash-2.0.0 → py_multihash-3.0.0}/docs/index.rst +3 -1
- {py-multihash-2.0.0 → py_multihash-3.0.0}/docs/installation.rst +1 -1
- py_multihash-3.0.0/docs/modules.rst +7 -0
- py_multihash-3.0.0/docs/multihash.rst +45 -0
- py_multihash-3.0.0/docs/usage.rst +280 -0
- py_multihash-3.0.0/multihash/__init__.py +62 -0
- py_multihash-3.0.0/multihash/constants.py +370 -0
- py_multihash-3.0.0/multihash/exceptions.py +31 -0
- py_multihash-3.0.0/multihash/funcs.py +789 -0
- py_multihash-3.0.0/multihash/multihash.py +941 -0
- py_multihash-3.0.0/py_multihash.egg-info/PKG-INFO +107 -0
- {py-multihash-2.0.0 → py_multihash-3.0.0}/py_multihash.egg-info/SOURCES.txt +8 -12
- py_multihash-3.0.0/py_multihash.egg-info/requires.txt +22 -0
- py_multihash-3.0.0/pyproject.toml +176 -0
- py_multihash-3.0.0/setup.cfg +4 -0
- py_multihash-3.0.0/tests/test_funcs.py +207 -0
- py_multihash-3.0.0/tests/test_multihash.py +330 -0
- py_multihash-3.0.0/tests/test_new_features.py +887 -0
- py-multihash-2.0.0/CONTRIBUTING.rst +0 -128
- py-multihash-2.0.0/HISTORY.rst +0 -12
- py-multihash-2.0.0/PKG-INFO +0 -61
- py-multihash-2.0.0/README.rst +0 -27
- py-multihash-2.0.0/docs/_build/html/_static/ajax-loader.gif +0 -0
- py-multihash-2.0.0/docs/_build/html/_static/comment-bright.png +0 -0
- py-multihash-2.0.0/docs/_build/html/_static/comment-close.png +0 -0
- py-multihash-2.0.0/docs/_build/html/_static/comment.png +0 -0
- py-multihash-2.0.0/docs/_build/html/_static/down-pressed.png +0 -0
- py-multihash-2.0.0/docs/_build/html/_static/down.png +0 -0
- py-multihash-2.0.0/docs/_build/html/_static/up-pressed.png +0 -0
- py-multihash-2.0.0/docs/_build/html/_static/up.png +0 -0
- py-multihash-2.0.0/docs/usage.rst +0 -7
- py-multihash-2.0.0/multihash/__init__.py +0 -12
- py-multihash-2.0.0/multihash/constants.py +0 -343
- py-multihash-2.0.0/multihash/multihash.py +0 -220
- py-multihash-2.0.0/py_multihash.egg-info/PKG-INFO +0 -61
- py-multihash-2.0.0/py_multihash.egg-info/requires.txt +0 -4
- py-multihash-2.0.0/setup.cfg +0 -42
- py-multihash-2.0.0/setup.py +0 -58
- py-multihash-2.0.0/tests/.coverage +0 -1
- py-multihash-2.0.0/tests/test_multihash.py +0 -344
- {py-multihash-2.0.0 → py_multihash-3.0.0}/AUTHORS.rst +0 -0
- {py-multihash-2.0.0 → py_multihash-3.0.0}/MANIFEST.in +0 -0
- {py-multihash-2.0.0 → py_multihash-3.0.0}/docs/Makefile +0 -0
- {py-multihash-2.0.0 → py_multihash-3.0.0}/docs/_build/html/_static/file.png +0 -0
- {py-multihash-2.0.0 → py_multihash-3.0.0}/docs/_build/html/_static/minus.png +0 -0
- {py-multihash-2.0.0 → py_multihash-3.0.0}/docs/_build/html/_static/plus.png +0 -0
- {py-multihash-2.0.0 → py_multihash-3.0.0}/docs/authors.rst +0 -0
- {py-multihash-2.0.0 → py_multihash-3.0.0}/docs/contributing.rst +0 -0
- {py-multihash-2.0.0 → py_multihash-3.0.0}/docs/history.rst +0 -0
- {py-multihash-2.0.0 → py_multihash-3.0.0}/docs/make.bat +0 -0
- {py-multihash-2.0.0 → py_multihash-3.0.0}/docs/readme.rst +0 -0
- {py-multihash-2.0.0 → py_multihash-3.0.0}/py_multihash.egg-info/dependency_links.txt +0 -0
- {py-multihash-2.0.0 → py_multihash-3.0.0}/py_multihash.egg-info/not-zip-safe +0 -0
- {py-multihash-2.0.0 → py_multihash-3.0.0}/py_multihash.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
.. highlight:: shell
|
|
2
|
+
|
|
3
|
+
============
|
|
4
|
+
Contributing
|
|
5
|
+
============
|
|
6
|
+
|
|
7
|
+
Contributions are welcome, and they are greatly appreciated! Every little bit
|
|
8
|
+
helps, and credit will always be given.
|
|
9
|
+
|
|
10
|
+
You can contribute in many ways:
|
|
11
|
+
|
|
12
|
+
Types of Contributions
|
|
13
|
+
----------------------
|
|
14
|
+
|
|
15
|
+
Report Bugs
|
|
16
|
+
~~~~~~~~~~~
|
|
17
|
+
|
|
18
|
+
Report bugs at https://github.com/multiformats/py-multihash/issues.
|
|
19
|
+
|
|
20
|
+
If you are reporting a bug, please include:
|
|
21
|
+
|
|
22
|
+
* Your operating system name and version.
|
|
23
|
+
* Any details about your local setup that might be helpful in troubleshooting.
|
|
24
|
+
* Detailed steps to reproduce the bug.
|
|
25
|
+
|
|
26
|
+
Fix Bugs
|
|
27
|
+
~~~~~~~~
|
|
28
|
+
|
|
29
|
+
Look through the GitHub issues for bugs. Anything tagged with "bug" and "help
|
|
30
|
+
wanted" is open to whoever wants to implement it.
|
|
31
|
+
|
|
32
|
+
Implement Features
|
|
33
|
+
~~~~~~~~~~~~~~~~~~
|
|
34
|
+
|
|
35
|
+
Look through the GitHub issues for features. Anything tagged with "enhancement"
|
|
36
|
+
and "help wanted" is open to whoever wants to implement it.
|
|
37
|
+
|
|
38
|
+
Write Documentation
|
|
39
|
+
~~~~~~~~~~~~~~~~~~~
|
|
40
|
+
|
|
41
|
+
py-multihash could always use more documentation, whether as part of the
|
|
42
|
+
official py-multihash docs, in docstrings, or even on the web in blog posts,
|
|
43
|
+
articles, and such.
|
|
44
|
+
|
|
45
|
+
Submit Feedback
|
|
46
|
+
~~~~~~~~~~~~~~~
|
|
47
|
+
|
|
48
|
+
The best way to send feedback is to file an issue at https://github.com/multiformats/py-multihash/issues.
|
|
49
|
+
|
|
50
|
+
If you are proposing a feature:
|
|
51
|
+
|
|
52
|
+
* Explain in detail how it would work.
|
|
53
|
+
* Keep the scope as narrow as possible, to make it easier to implement.
|
|
54
|
+
* Remember that this is a volunteer-driven project, and that contributions
|
|
55
|
+
are welcome :)
|
|
56
|
+
|
|
57
|
+
Get Started!
|
|
58
|
+
------------
|
|
59
|
+
|
|
60
|
+
Ready to contribute? Here's how to set up `multihash` for local development.
|
|
61
|
+
|
|
62
|
+
1. Fork the `py-multihash` repo on GitHub.
|
|
63
|
+
2. Clone your fork locally::
|
|
64
|
+
|
|
65
|
+
$ git clone git@github.com:your_name_here/py-multihash.git
|
|
66
|
+
|
|
67
|
+
3. Install your local copy into a virtualenv. Create and activate a virtual environment::
|
|
68
|
+
|
|
69
|
+
$ python -m venv venv
|
|
70
|
+
$ source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
71
|
+
$ pip install -e ".[dev]"
|
|
72
|
+
|
|
73
|
+
4. Create a branch for local development::
|
|
74
|
+
|
|
75
|
+
$ git checkout -b name-of-your-bugfix-or-feature
|
|
76
|
+
|
|
77
|
+
Now you can make your changes locally.
|
|
78
|
+
|
|
79
|
+
5. When you're done making changes, check that your changes pass linting and the
|
|
80
|
+
tests, including testing other Python versions with tox::
|
|
81
|
+
|
|
82
|
+
$ make lint
|
|
83
|
+
$ make test
|
|
84
|
+
$ tox
|
|
85
|
+
|
|
86
|
+
Or install development dependencies and run pre-commit::
|
|
87
|
+
|
|
88
|
+
$ pip install -e ".[dev]"
|
|
89
|
+
$ pre-commit run --all-files
|
|
90
|
+
|
|
91
|
+
6. Commit your changes and push your branch to GitHub::
|
|
92
|
+
|
|
93
|
+
$ git add .
|
|
94
|
+
$ git commit -m "Your detailed description of your changes."
|
|
95
|
+
$ git push -u origin name-of-your-bugfix-or-feature
|
|
96
|
+
|
|
97
|
+
7. Submit a pull request through the GitHub website.
|
|
98
|
+
|
|
99
|
+
Pull Request Guidelines
|
|
100
|
+
-----------------------
|
|
101
|
+
|
|
102
|
+
Before you submit a pull request, check that it meets these guidelines:
|
|
103
|
+
|
|
104
|
+
1. The pull request should include tests.
|
|
105
|
+
2. If the pull request adds functionality, the docs should be updated. Put
|
|
106
|
+
your new functionality into a function with a docstring, and add the
|
|
107
|
+
feature to the list in README.rst.
|
|
108
|
+
3. The pull request should work for Python 3.10, 3.11, 3.12, 3.13, and 3.14. Check
|
|
109
|
+
https://github.com/multiformats/py-multihash/actions
|
|
110
|
+
and make sure that the tests pass for all supported Python versions.
|
|
111
|
+
|
|
112
|
+
Tips
|
|
113
|
+
----
|
|
114
|
+
|
|
115
|
+
To run a subset of tests::
|
|
116
|
+
|
|
117
|
+
$ pytest tests/test_multihash.py
|
|
118
|
+
|
|
119
|
+
Releasing
|
|
120
|
+
---------
|
|
121
|
+
|
|
122
|
+
Releases are typically done from the ``master`` branch, except when releasing a beta (in
|
|
123
|
+
which case the beta is released from ``master``, and the previous stable branch is
|
|
124
|
+
released from said branch).
|
|
125
|
+
|
|
126
|
+
Final test before each release
|
|
127
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
128
|
+
|
|
129
|
+
Before releasing a new version, build and test the package that will be released:
|
|
130
|
+
|
|
131
|
+
.. code:: sh
|
|
132
|
+
|
|
133
|
+
git checkout master && git pull
|
|
134
|
+
make package-test
|
|
135
|
+
|
|
136
|
+
This will build the package and install it in a temporary virtual environment. Follow
|
|
137
|
+
the instructions to activate the venv and test whatever you think is important.
|
|
138
|
+
|
|
139
|
+
You can also preview the release notes:
|
|
140
|
+
|
|
141
|
+
.. code:: sh
|
|
142
|
+
|
|
143
|
+
towncrier --draft
|
|
144
|
+
|
|
145
|
+
Build the release notes
|
|
146
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
147
|
+
|
|
148
|
+
Before bumping the version number, build the release notes. You must include the part of
|
|
149
|
+
the version to bump (see below), which changes how the version number will show in the
|
|
150
|
+
release notes.
|
|
151
|
+
|
|
152
|
+
.. code:: sh
|
|
153
|
+
|
|
154
|
+
make notes bump=$$VERSION_PART_TO_BUMP$$
|
|
155
|
+
|
|
156
|
+
If there are any errors, be sure to re-run make notes until it works.
|
|
157
|
+
|
|
158
|
+
Push the release to github & pypi
|
|
159
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
160
|
+
|
|
161
|
+
After confirming that the release package looks okay, release a new version:
|
|
162
|
+
|
|
163
|
+
.. code:: sh
|
|
164
|
+
|
|
165
|
+
make release bump=$$VERSION_PART_TO_BUMP$$
|
|
166
|
+
|
|
167
|
+
This command will:
|
|
168
|
+
|
|
169
|
+
- Bump the version number as specified wherever it appears in the repo.
|
|
170
|
+
- Create a git commit and tag for the new version.
|
|
171
|
+
- Build the package.
|
|
172
|
+
- Push the commit and tag to github.
|
|
173
|
+
- Push the new package files to pypi.
|
|
174
|
+
|
|
175
|
+
Which version part to bump
|
|
176
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
177
|
+
|
|
178
|
+
``$$VERSION_PART_TO_BUMP$$`` must be one of: ``major``, ``minor``, ``patch``, ``stage``,
|
|
179
|
+
or ``devnum``.
|
|
180
|
+
|
|
181
|
+
The version format for this repo is ``{major}.{minor}.{patch}`` for stable, and
|
|
182
|
+
``{major}.{minor}.{patch}-{stage}.{devnum}`` for unstable (``stage`` can be alpha or
|
|
183
|
+
beta).
|
|
184
|
+
|
|
185
|
+
If you are in a beta version, ``make release bump=stage`` will switch to a stable.
|
|
186
|
+
|
|
187
|
+
To issue an unstable version when the current version is stable, specify the new version
|
|
188
|
+
explicitly, like ``make release bump="--new-version 4.0.0-alpha.1"``
|
|
189
|
+
|
|
190
|
+
You can see what the result of bumping any particular version part would be with
|
|
191
|
+
``bump-my-version show-bump``
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
History
|
|
2
|
+
=======
|
|
3
|
+
|
|
4
|
+
.. towncrier release notes start
|
|
5
|
+
|
|
6
|
+
py-multihash v3.0.0 (2025-12-17)
|
|
7
|
+
--------------------------------
|
|
8
|
+
|
|
9
|
+
Bugfixes
|
|
10
|
+
~~~~~~~~
|
|
11
|
+
|
|
12
|
+
- Added type annotations for ``Multihash`` namedtuple fields (``code``, ``name``, ``length``, ``digest``) to fix static type checker errors. (`#24 <https://github.com/multiformats/py-multihash/issues/24>`__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
Features
|
|
16
|
+
~~~~~~~~
|
|
17
|
+
|
|
18
|
+
- Added pymultihash-compatible APIs to enable py-libp2p migration from the archived pymultihash package. (`#19 <https://github.com/multiformats/py-multihash/issues/19>`__)
|
|
19
|
+
- Added streaming hash computation, truncation support, Go-compatible sum() function, SHAKE variable-length hash support, custom exception hierarchy, and additional hash functions (SHA2-224, SHA2-384) to achieve feature parity with other multihash implementations. Also added MultihashSet collection type and JSON serialization support (to_json/from_json) for Priority 3 features. (`#21 <https://github.com/multiformats/py-multihash/issues/21>`__)
|
|
20
|
+
- Added BLAKE3, MurmurHash3 (32-bit and 128-bit), and double-SHA-256 hash functions. (`#26 <https://github.com/multiformats/py-multihash/issues/26>`__)
|
|
21
|
+
- Add stream I/O methods ``Multihash.read()`` and ``Multihash.write()`` for reading and writing multihashes from/to binary streams. (`#30 <https://github.com/multiformats/py-multihash/issues/30>`__)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
Internal Changes - for py-multihash Contributors
|
|
25
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
26
|
+
|
|
27
|
+
- Modernized project setup and infrastructure. Migrated from legacy setup.py/setup.cfg to modern pyproject.toml, replaced Travis CI with GitHub Actions, updated Python version support to 3.10-3.14, replaced flake8 with ruff, and added pre-commit hooks. This is an internal change that does not affect the public API. (`#17 <https://github.com/multiformats/py-multihash/issues/17>`__)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
Miscellaneous Changes
|
|
31
|
+
~~~~~~~~~~~~~~~~~~~~~
|
|
32
|
+
|
|
33
|
+
- `#18 <https://github.com/multiformats/py-multihash/issues/18>`__
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
0.2.3 (2018-10-20)
|
|
37
|
+
------------------
|
|
38
|
+
* Fix issue with decoding breaking with app codes
|
|
39
|
+
* Fix issue with invalid varint decoding
|
|
40
|
+
|
|
41
|
+
0.1.0 (2018-10-19)
|
|
42
|
+
------------------
|
|
43
|
+
|
|
44
|
+
* First release on PyPI.
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: py-multihash
|
|
3
|
+
Version: 3.0.0
|
|
4
|
+
Summary: Multihash implementation in Python
|
|
5
|
+
Author-email: Dhruv Baldawa <dhruv@dhruvb.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/multiformats/multihash
|
|
8
|
+
Project-URL: Download, https://github.com/multiformats/multihash/tarball/3.0.0
|
|
9
|
+
Keywords: multihash
|
|
10
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Natural Language :: English
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Requires-Python: <4.0,>=3.10
|
|
20
|
+
Description-Content-Type: text/x-rst
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
License-File: AUTHORS.rst
|
|
23
|
+
Requires-Dist: varint<2.0,>=1.0.2
|
|
24
|
+
Requires-Dist: six<2.0,>=1.10.0
|
|
25
|
+
Requires-Dist: morphys<2.0,>=1.0
|
|
26
|
+
Requires-Dist: base58<3.0,>=1.0.2
|
|
27
|
+
Requires-Dist: blake3<2.0,>=0.3.0
|
|
28
|
+
Requires-Dist: mmh3<6.0,>=3.0.0
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: Sphinx>=5.0.0; extra == "dev"
|
|
31
|
+
Requires-Dist: build>=0.9.0; extra == "dev"
|
|
32
|
+
Requires-Dist: bump-my-version>=1.2.0; extra == "dev"
|
|
33
|
+
Requires-Dist: mypy; extra == "dev"
|
|
34
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest; extra == "dev"
|
|
36
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
37
|
+
Requires-Dist: pytest-runner; extra == "dev"
|
|
38
|
+
Requires-Dist: ruff; extra == "dev"
|
|
39
|
+
Requires-Dist: towncrier<25,>=24; extra == "dev"
|
|
40
|
+
Requires-Dist: tox>=4.10.0; extra == "dev"
|
|
41
|
+
Requires-Dist: twine; extra == "dev"
|
|
42
|
+
Requires-Dist: watchdog>=3.0.0; extra == "dev"
|
|
43
|
+
Requires-Dist: wheel>=0.31.0; extra == "dev"
|
|
44
|
+
Dynamic: license-file
|
|
45
|
+
|
|
46
|
+
============
|
|
47
|
+
py-multihash
|
|
48
|
+
============
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
.. image:: https://img.shields.io/pypi/v/py-multihash.svg
|
|
52
|
+
:target: https://pypi.python.org/pypi/py-multihash
|
|
53
|
+
|
|
54
|
+
.. image:: https://github.com/multiformats/py-multihash/actions/workflows/tox.yml/badge.svg
|
|
55
|
+
:target: https://github.com/multiformats/py-multihash/actions
|
|
56
|
+
|
|
57
|
+
.. image:: https://readthedocs.org/projects/multihash/badge/?version=latest
|
|
58
|
+
:target: https://multihash.readthedocs.io/en/latest/?badge=latest
|
|
59
|
+
:alt: Documentation Status
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
Multihash implementation in Python
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
* Free software: MIT license
|
|
67
|
+
* Documentation: https://multihash.readthedocs.io.
|
|
68
|
+
* Python versions: Python 3.10, 3.11, 3.12, 3.13, 3.14
|
|
69
|
+
|
|
70
|
+
Features
|
|
71
|
+
--------
|
|
72
|
+
|
|
73
|
+
* Support for 125+ hash functions including:
|
|
74
|
+
|
|
75
|
+
* **Cryptographic hashes**: SHA-1, SHA-2 (224/256/384/512), SHA-3, BLAKE2b, BLAKE2s, BLAKE3
|
|
76
|
+
* **Variable-length hashes**: SHAKE-128, SHAKE-256
|
|
77
|
+
* **Non-cryptographic hashes**: MurmurHash3 (32-bit and 128-bit)
|
|
78
|
+
* **Specialized hashes**: Double-SHA-256 (Bitcoin), Keccak, and more
|
|
79
|
+
* **BLAKE2 variants**: Full range of digest sizes (8-512 bits for BLAKE2b, 8-256 bits for BLAKE2s)
|
|
80
|
+
|
|
81
|
+
* Streaming hash computation for large files
|
|
82
|
+
* Hash truncation support
|
|
83
|
+
* JSON serialization
|
|
84
|
+
* MultihashSet collection type
|
|
85
|
+
* Go-compatible API (``sum()``, ``digest()``, ``verify()``)
|
|
86
|
+
|
|
87
|
+
Quick Start
|
|
88
|
+
-----------
|
|
89
|
+
|
|
90
|
+
.. code-block:: python
|
|
91
|
+
|
|
92
|
+
from multihash import digest, sum, Func
|
|
93
|
+
|
|
94
|
+
# Using modern hash functions
|
|
95
|
+
mh = digest(b"hello world", "blake3")
|
|
96
|
+
|
|
97
|
+
# Using MurmurHash3 for fast, non-cryptographic hashing
|
|
98
|
+
mh = digest(b"data", "murmur3-128")
|
|
99
|
+
|
|
100
|
+
# Using BLAKE2b with custom digest size
|
|
101
|
+
mh = digest(b"data", "blake2b-256")
|
|
102
|
+
|
|
103
|
+
# Go-compatible API
|
|
104
|
+
mh = sum(b"hello world", Func.sha2_256)
|
|
105
|
+
print(mh.encode('hex'))
|
|
106
|
+
|
|
107
|
+
For more examples and usage, see the documentation.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
============
|
|
2
|
+
py-multihash
|
|
3
|
+
============
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
.. image:: https://img.shields.io/pypi/v/py-multihash.svg
|
|
7
|
+
:target: https://pypi.python.org/pypi/py-multihash
|
|
8
|
+
|
|
9
|
+
.. image:: https://github.com/multiformats/py-multihash/actions/workflows/tox.yml/badge.svg
|
|
10
|
+
:target: https://github.com/multiformats/py-multihash/actions
|
|
11
|
+
|
|
12
|
+
.. image:: https://readthedocs.org/projects/multihash/badge/?version=latest
|
|
13
|
+
:target: https://multihash.readthedocs.io/en/latest/?badge=latest
|
|
14
|
+
:alt: Documentation Status
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
Multihash implementation in Python
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
* Free software: MIT license
|
|
22
|
+
* Documentation: https://multihash.readthedocs.io.
|
|
23
|
+
* Python versions: Python 3.10, 3.11, 3.12, 3.13, 3.14
|
|
24
|
+
|
|
25
|
+
Features
|
|
26
|
+
--------
|
|
27
|
+
|
|
28
|
+
* Support for 125+ hash functions including:
|
|
29
|
+
|
|
30
|
+
* **Cryptographic hashes**: SHA-1, SHA-2 (224/256/384/512), SHA-3, BLAKE2b, BLAKE2s, BLAKE3
|
|
31
|
+
* **Variable-length hashes**: SHAKE-128, SHAKE-256
|
|
32
|
+
* **Non-cryptographic hashes**: MurmurHash3 (32-bit and 128-bit)
|
|
33
|
+
* **Specialized hashes**: Double-SHA-256 (Bitcoin), Keccak, and more
|
|
34
|
+
* **BLAKE2 variants**: Full range of digest sizes (8-512 bits for BLAKE2b, 8-256 bits for BLAKE2s)
|
|
35
|
+
|
|
36
|
+
* Streaming hash computation for large files
|
|
37
|
+
* Hash truncation support
|
|
38
|
+
* JSON serialization
|
|
39
|
+
* MultihashSet collection type
|
|
40
|
+
* Go-compatible API (``sum()``, ``digest()``, ``verify()``)
|
|
41
|
+
|
|
42
|
+
Quick Start
|
|
43
|
+
-----------
|
|
44
|
+
|
|
45
|
+
.. code-block:: python
|
|
46
|
+
|
|
47
|
+
from multihash import digest, sum, Func
|
|
48
|
+
|
|
49
|
+
# Using modern hash functions
|
|
50
|
+
mh = digest(b"hello world", "blake3")
|
|
51
|
+
|
|
52
|
+
# Using MurmurHash3 for fast, non-cryptographic hashing
|
|
53
|
+
mh = digest(b"data", "murmur3-128")
|
|
54
|
+
|
|
55
|
+
# Using BLAKE2b with custom digest size
|
|
56
|
+
mh = digest(b"data", "blake2b-256")
|
|
57
|
+
|
|
58
|
+
# Go-compatible API
|
|
59
|
+
mh = sum(b"hello world", Func.sha2_256)
|
|
60
|
+
print(mh.encode('hex'))
|
|
61
|
+
|
|
62
|
+
For more examples and usage, see the documentation.
|
|
@@ -4,25 +4,37 @@ API Reference
|
|
|
4
4
|
.. py:currentmodule:: multihash
|
|
5
5
|
|
|
6
6
|
.. autofunction:: encode
|
|
7
|
+
:no-index:
|
|
7
8
|
|
|
8
9
|
.. autofunction:: decode
|
|
10
|
+
:no-index:
|
|
9
11
|
|
|
10
12
|
.. autofunction:: is_valid
|
|
13
|
+
:no-index:
|
|
11
14
|
|
|
12
15
|
.. autofunction:: is_valid_code
|
|
16
|
+
:no-index:
|
|
13
17
|
|
|
14
18
|
.. autofunction:: get_prefix
|
|
19
|
+
:no-index:
|
|
15
20
|
|
|
16
21
|
.. autofunction:: coerce_code
|
|
22
|
+
:no-index:
|
|
17
23
|
|
|
18
24
|
.. autofunction:: is_app_code
|
|
25
|
+
:no-index:
|
|
19
26
|
|
|
20
27
|
.. autofunction:: to_hex_string
|
|
28
|
+
:no-index:
|
|
21
29
|
|
|
22
30
|
.. autofunction:: from_hex_string
|
|
31
|
+
:no-index:
|
|
23
32
|
|
|
24
33
|
.. autofunction:: to_b58_string
|
|
34
|
+
:no-index:
|
|
25
35
|
|
|
26
36
|
.. autofunction:: from_b58_string
|
|
37
|
+
:no-index:
|
|
27
38
|
|
|
28
39
|
.. autoclass:: Multihash
|
|
40
|
+
:no-index:
|
|
@@ -32,7 +32,17 @@ import multihash
|
|
|
32
32
|
|
|
33
33
|
# Add any Sphinx extension module names here, as strings. They can be
|
|
34
34
|
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
|
35
|
-
extensions = [
|
|
35
|
+
extensions = [
|
|
36
|
+
'sphinx.ext.autodoc',
|
|
37
|
+
'sphinx.ext.viewcode',
|
|
38
|
+
'sphinx.ext.doctest',
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
# Doctest configuration
|
|
42
|
+
doctest_global_setup = """
|
|
43
|
+
from multihash import Multihash, MultihashSet, from_json, sum, digest
|
|
44
|
+
from multihash.funcs import Func, Blake3Hash, Murmur3_128Hash, Murmur3_32Hash, DoubleSHA256Hash
|
|
45
|
+
"""
|
|
36
46
|
|
|
37
47
|
# Add any paths that contain templates here, relative to this directory.
|
|
38
48
|
templates_path = ['_templates']
|
|
@@ -65,7 +75,7 @@ release = multihash.__version__
|
|
|
65
75
|
#
|
|
66
76
|
# This is also used if you do content translation via gettext catalogs.
|
|
67
77
|
# Usually you set "language" from the command line for these cases.
|
|
68
|
-
language =
|
|
78
|
+
language = 'en'
|
|
69
79
|
|
|
70
80
|
# List of patterns, relative to source directory, that match files and
|
|
71
81
|
# directories to ignore when looking for source files.
|
|
@@ -94,7 +104,7 @@ html_theme = 'alabaster'
|
|
|
94
104
|
# Add any paths that contain custom static files (such as style sheets) here,
|
|
95
105
|
# relative to this directory. They are copied after the builtin static files,
|
|
96
106
|
# so a file named "default.css" will overwrite the builtin "default.css".
|
|
97
|
-
html_static_path = ['_static']
|
|
107
|
+
# html_static_path = ['_static']
|
|
98
108
|
|
|
99
109
|
|
|
100
110
|
# -- Options for HTMLHelp output ---------------------------------------
|
|
@@ -175,4 +185,3 @@ texinfo_documents = [
|
|
|
175
185
|
]
|
|
176
186
|
|
|
177
187
|
|
|
178
|
-
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
multihash package
|
|
2
|
+
=================
|
|
3
|
+
|
|
4
|
+
Submodules
|
|
5
|
+
----------
|
|
6
|
+
|
|
7
|
+
multihash.constants module
|
|
8
|
+
--------------------------
|
|
9
|
+
|
|
10
|
+
.. automodule:: multihash.constants
|
|
11
|
+
:members:
|
|
12
|
+
:show-inheritance:
|
|
13
|
+
:undoc-members:
|
|
14
|
+
|
|
15
|
+
multihash.exceptions module
|
|
16
|
+
---------------------------
|
|
17
|
+
|
|
18
|
+
.. automodule:: multihash.exceptions
|
|
19
|
+
:members:
|
|
20
|
+
:show-inheritance:
|
|
21
|
+
:undoc-members:
|
|
22
|
+
|
|
23
|
+
multihash.funcs module
|
|
24
|
+
----------------------
|
|
25
|
+
|
|
26
|
+
.. automodule:: multihash.funcs
|
|
27
|
+
:members:
|
|
28
|
+
:show-inheritance:
|
|
29
|
+
:undoc-members:
|
|
30
|
+
|
|
31
|
+
multihash.multihash module
|
|
32
|
+
--------------------------
|
|
33
|
+
|
|
34
|
+
.. automodule:: multihash.multihash
|
|
35
|
+
:members:
|
|
36
|
+
:show-inheritance:
|
|
37
|
+
:undoc-members:
|
|
38
|
+
|
|
39
|
+
Module contents
|
|
40
|
+
---------------
|
|
41
|
+
|
|
42
|
+
.. automodule:: multihash
|
|
43
|
+
:members:
|
|
44
|
+
:show-inheritance:
|
|
45
|
+
:undoc-members:
|