Skip to main content

Python drop-in replacement for md5sum and co.

Project description

HomePage:

https://github.com/avalentino/hashsum

Latest Version Supported Python versions License GHA status page Coverage Status

Usage

usage: hashsum [-h] [-a] [--tag] [-b | -t] [-c | -l] [--quiet]
               [--status] [--strict] [-w] [-m] [--version]
               [FILE [FILE ...]]

Compute and check message digest with different hash algorithms.
The sums are computed as described in [1].
When checking, the input should be a former output of this program.
The default mode is to print a line with checksum, a character
indicating input mode ('*' for binary, space for text), and name
for each FILE.

[1] https://docs.python.org/3/library/hashlib.html

positional arguments:
  FILE                  name of file to process. If not specified,
                        or set to -, data are read form the
                        standard input

optional arguments:
  -h, --help            show this help message and exit
  -a , --algorithm      specify the hashing algorithm
                        (default: 'md5')
  --tag                 create a BSD-style checksum
  -b, --binary          read input data in binary mode
  -t, --text            read input data in text mode (default)
  -c, --check           read checksum(s) form FILE and check them
  -l, --list-algorithms
                        list available hashing algorithms
  -m, --multi-thread    perform I/O and hash computation in separate threads
                        (default=False). Can speed-up computation on large
                        files while it is not recommended for small files.
  --version             show program's version number and exit

check:
  Options that are useful only when verifying checksums

  --quiet               don't print OK for each successfully
                        verified file
  --status              don't output anything, status code shows
                        success
  --strict              exit non-zero for improperly formatted
                        checksum lines
  -w, --warn            warn about improperly formatted checksum
                        lines

Package testing

The recommended way to test the package is to use pytest:

$ python3 -m pytest -v

========================== test session starts ==========================
platform linux -- Python 3.9.5, pytest-6.0.2, py-1.10.0, pluggy-0.13.0
hashsum version:      1.4.0.dev0
Platform:             Linux-5.11.0-24-generic-x86_64-with-glibc2.33
Byte-ordering:        little
Default encoding:     utf-8
Default FS encoding:  utf-8
Default locale:       ('it_IT', 'UTF-8')
rootdir: /home/antonio/projects/hashsum, configfile: setup.cfg
plugins: hypothesis-5.43.3, remotedata-0.3.2, doctestplus-0.9.0,
        openfiles-0.5.0, flake8-1.0.6, filter-subpackage-0.1.1, cov-2.10.1
collected 26 items

tests/test_hashsum.py::ComputeSumTestCase::test_binary PASSED       [  3%]
tests/test_hashsum.py::ComputeSumTestCase::test_binary_auto PASSED  [  7%]

[...]

tests/test_hashsum.py::ThreadedCheckTestCase::test_text PASSED      [100%]

========================== 26 passed in 0.29s ===========================

Please note that some basic system information that can be sued for bug reporting are also printed on the screen.

The default configuration for “pytest” is stored into the setup.cfg file in the root directory of the source package:

[tool:pytest]
addopts = -p no:warnings -p no:logging

Alternatively it is possible to use:

$ python3 -m unittest -v tests/test_hashsum.py

License

The hashsum software is distribute under the terms of the “3-Clause BSD License” see LICENSE.txt file for details.

hashsum changelog

hashsum v1.4.1 (18/07/2021)

  • Fix the wheel generation: generated wheel are not universal, they only work with Python 3.6 and higher

hashsum v1.4.0 (18/07/2021)

  • Drop support for Python < 3.6.

  • Switch to GitHub Actions for CI.

  • Fix verification of checksums in text mode on Windows.

  • Re-factorize and simplify the test code.

  • Add buildsystem support (pyproject.toml)

  • Switch to declarative setup configuration (setup.cfg).

hashsum v1.3.0 (25/08/2019)

  • hashsum.VERSION renamed into hashsum.__version__

  • added test utility functions

  • prefer lowercase names for hash functions

  • improve robustness against unknown/unavailable hash functions in threaded checksum computation

  • new –failfast option added to the test CLI

  • improved benchmark script

  • man page updated

  • improved compatibility with pytest

hashsum v1.2.2 (15/11/2016)

  • Fix compatibility with the windows operating system

hashsum v1.2.1 (24/08/2016)

  • Minor packaging fixes

hashsum v1.2.0 (24/08/2016)

  • Improved compatibility with the OpenSSL command line tool

  • Better iteration on data blocks

  • Optional threaded hash computation

  • Refactoring: the entire code has been re-organized in tools

  • Drop all gettext related files

hashsum v1.1.1 (30/01/2016)

  • Include man pages in the tarball

hashsum v1.1 (30/01/2016)

  • Fixed IncrementalNewlineDecoder.decoder signature

  • Always call decode with final=True when reading in text mode

  • Factorized code for checksum computation

  • All Exceptions are now trapped in the main function

  • Added unit testing

  • Code cleanup

  • Added NEWS.rst file

  • Added man page

  • Improved command line help (also fixed some typos)

  • Enabled automatic testing with travis-ci

hashsum v1.0 (04/01/2016)

  • Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hashsum-1.4.1.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

hashsum-1.4.1-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file hashsum-1.4.1.tar.gz.

File metadata

  • Download URL: hashsum-1.4.1.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.5

File hashes

Hashes for hashsum-1.4.1.tar.gz
Algorithm Hash digest
SHA256 2c40505ab82578651f9875241c48d03a1149c36eabd858907b7f3ab047a8c5e7
MD5 9f0c1d2fddaa98e0c7865db490459507
BLAKE2b-256 b52e755f43f8bac40b31976252ad86bf44118819822cab61de85b39e8e19bd45

See more details on using hashes here.

File details

Details for the file hashsum-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: hashsum-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.5

File hashes

Hashes for hashsum-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0092627a2ce2c444d8493ed11d24962b751e6b8c488ae231d7407a34305f94c3
MD5 3e61bfffc74f4d00e90012e0d617cf00
BLAKE2b-256 c1b28969b68a3d22ffa4408d3f88070c7d0bed050ebb5cc9da2c2af8770c8087

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page