RHash
RHash is a Python library for computing various message digests, including CRC32, CRC32C, MD4, MD5, SHA1, SHA2, SHA3, AICH, ED2K, DC++ TTH, Tiger, BitTorrent BTIH, GOST R 34.11-94, GOST R 34.11-2012, RIPEMD-160, HAS-160, BLAKE2s, BLAKE2b, EDON-R, and Whirlpool.
Installation
RHash requires LibRHash library. The LibRHash sources or Windows binaries can be downloaded from:
Linux and BSD users should install LibRHash from the official repository.
To build LibRHash from sources use commands
$ ./configure
$ make lib-shared install-lib-shared
In order to be loaded by RHash Python module, the LibRHash library should be placed in the appropriate directory or you can change required environment variable.
To install the RHash Python module use the package manager pip
$ pip install rhash-Rhash
You can also build the module from source
$ python3 -m build
Usage
Hashing a file or a text message can be done using RHash hi-level interface
>>> import rhash
>>> rhash.hash_file("input-file.txt", rhash.SHA3_256)
'a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a'
>>> rhash.make_magnet("input-file.txt", rhash.CRC32, rhash.TTH)
'magnet:?xl=0&dn=input-file.txt&xt=urn:crc32:00000000&xt=urn:tree:tiger:lwpnacqdbzryxw3vhjvcj64qbznghohhhzwclnq'
>>> message_digest = rhash.hash_msg("abc", rhash.SHA1)
>>> print("SHA1 (\"abc\") = {}".format(message_digest))
SHA1 ("abc") = a9993e364706816aba3e25717850c26c9cd0d89d
The Low-level interface allows to calculate several message digests at once and output them in different formats
>>> import rhash
>>> h = rhash.RHash(rhash.MD5, rhash.SHA1, rhash.BLAKE2S)
>>> h.update("abc")
<rhash.rhash.RHash object at 0x7fc512d90670>
>>> h.finish()
<rhash.rhash.RHash object at 0x7fc512d90670>
>>> h.hex(rhash.MD5)
'900150983cd24fb0d6963f7d28e17f72'
>>> h.hex_upper(rhash.MD5)
'900150983CD24FB0D6963F7D28E17F72'
>>> h.base32(rhash.SHA1)
'vgmt4nsha2awvor6evyxqugcnsonbwe5'
>>> h.base32_upper(rhash.SHA1)
'VGMT4NSHA2AWVOR6EVYXQUGCNSONBWE5'
>>> h.base64(rhash.BLAKE2S)
'UIxejDJ8FOLhpyujTutFLzdFiyCe1jopTZmbTIZnWYI='
The RHash object can be used within the with operator
import rhash
with rhash.RHash(rhash.MD5) as ctx:
ctx.update("a").finish()
print(ctx.hash(rhash.MD5))
Contribution
To contribute to the project, please read the Contribution guidelines document.
License
The code is distributed under the BSD Zero Clause License.
Metadata
Release files for rhash-Rhash 1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rhash_rhash-1.2.tar.gz | 7.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rhash_Rhash-1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.7 kB
Release files / rhash_rhash-1.2.tar.gz
| Download URL | rhash_rhash-1.2.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5f68aef6cb8efc99117d1edb17c88e139c234fb038edcbe5a59923817985de06
|
|
BLAKE2b-256 checksum How to use checksums |
79f02eb323426e1e580f6907e155d00b501cec54fd8f667e13b18f2f5f74199c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / rhash_Rhash-1.2-py3-none-any.whl
| Download URL | rhash_Rhash-1.2-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
08095231fd899821bcd2b4d7dbe6e06399ffd0930060be8f1393855d9ebefef7
|
|
BLAKE2b-256 checksum How to use checksums |
66676cc9ade565fb31a27a1a8e324318cce93cb967b2de3e9b3a927029267f68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|