calculate hash or checksum
Project description
hashfile calculates hashes or checksums in many formats, also verify them.
Default algorithm is sha1. This can be changed by passing argument -a/--algorithm to hashfile, or by calling hashfile with algorithm name (ie. using symlinks).
hashfile works pretty well with big files, because always read data partially, by default 4MB of data at once (it can be changed using --max-input-read param).
Examples
# simplest call % hashfile /etc/hosts sha1: 4f53fb6efebddfdbe989f3bff980cd07ebcdc6bb /etc/hosts # specify algorithm % hashfile -a md5 /etc/hosts md5: 71e875e9d194c18567f48cf9534ed6cf /etc/hosts # one file, many algorithms % hashfile -a md5 -a sha1 /etc/hosts /etc/hosts md5: 71e875e9d194c18567f48cf9534ed6cf /etc/hosts sha1: 4f53fb6efebddfdbe989f3bff980cd07ebcdc6bb /etc/hosts # many files, other algorithm for each one % hashfile -a md5 -a sha1 /etc/hosts /etc/shells md5: 71e875e9d194c18567f48cf9534ed6cf /etc/hosts sha1: e0de09cb8797a4d39f89049d74585e815a3c6ceb /etc/shells # many files, one algorithm % hashfile -a sha256 /etc/hosts /etc/shells sha256: 48127a192d62fdcaa39f7cebd1ea5f3fe660807c8cd3a92599406d16bddc341a /etc/hosts sha256: edfd1953cce18ab14449b657fcc01ece6a43a7075bab7b451f3186b885c20998 /etc/shells # choose algorithm using symlinks % ln -s `which hashfile` ~/bin/sha256 % sha256 /etc/hosts sha256: 48127a192d62fdcaa39f7cebd1ea5f3fe660807c8cd3a92599406d16bddc341a /etc/hosts # create verify file, and then verify % hashfile -a sha256 README.* > check.sum % hashfile -c check.sum README.md: OK README.rst: OK
Current stable version
2.1.5
Python version
hashfile works with Python 2.7+ and 3.3+.
Usage
Everything is in help :) Just execute:
hashfile --help
Look at result (remember: list of algorithms may vary on your system):
% hashfile --help usage: hashfile [-h] [--algorithm {adler32,crc32,md4,md5,mdc2,ripemd160,sha,sha1,sha224,sha256,sha384,sha512,whirlpool}] [--generate-algo-symlinks] [--check] [--quiet] [--status] [--warn] [--max-input-read MAX_INPUT_READ] [FILE [FILE ...]] Calculate hash of some files positional arguments: FILE list of files (stdin by default) optional arguments: -h, --help show this help message and exit --algorithm {adler32,crc32,md4,md5,mdc2,ripemd160,sha,sha1,sha224,sha256,sha384,sha512,whirlpool}, -a {adler32,crc32,md4,md5,mdc2,ripemd160,sha,sha1,sha224,sha256,sha384,sha512,whirlpool} algorithm used to calculate hash If given more then one, then use different algorithms for different files (use first algo to first file, second algo to second file etc. If there is more files then algorithms, last algorithm from list is used. --generate-algo-symlinks Show aliases for every algorithm handled by hashfile --check, -c read checksums from the FILEs and check them --quiet, -q don't print OK for each successfully verified file --status, -s don't output anything, status code shows success --warn, -w warn about improperly formatted checksum lines --max-input-read MAX_INPUT_READ maximum data size for read at once Algorithm can be also set from program name (for example call program as sha1 to use sha1 algorithm)
Installation
Using PIP
hashfile should work on any platform where Python is available, it means Linux, Windows, MacOS X etc.
Simplest way is to use Python’s built-in package system:
pip install hashfile
Using pipsi
pipsi install hashfile
Using sources
Download sources from Github:
wget -O 2.1.5.zip https://github.com/msztolcman/hashfile/archive/2.1.5.zip
or
curl -o 2.1.5.zip https://github.com/msztolcman/hashfile/archive/2.1.5.zip
Unpack:
unzip 2.1.5.zip
And install
cd hashfile-2.1.5 python setup.py install
Voila!
Contact
If you like or dislike this software, please do not hesitate to tell me about this me via email (marcin@urzenia.net).
If you find bug or have an idea to enhance this tool, please use GitHub’s issues.
License
The MIT License (MIT)
Copyright (c) 2012 Marcin Sztolcman
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
ChangeLog
v2.1.5
fixed reading binary data from stdin
v2.1.4
fixed working with binary files
hashfile is now a package
some package-related changes
few updates to Makefile
v2.1.3
fixed working with aliases
v2.1.2
another small improvements for PyPI
forgotten changelog
v2.1.1
small improvements for setup.py and PyPI
v2.1.0
added –version switch
v2.0.0
added compatibility with tools like md5sum or sha1sum (verify mode, call arguments compatibility, etc)
v1.0.0
First public version
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
Built Distribution
File details
Details for the file hashfile-2.1.5.tar.gz
.
File metadata
- Download URL: hashfile-2.1.5.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fe44fb103d94b4782636b93ea417cc3ba34e5f0f0a2d05b4886279a344fdf45 |
|
MD5 | cd28c3336bdef956a95d06fca23cf766 |
|
BLAKE2b-256 | 014fd9e5fc982451118cd67c0c7de7a14377d28ac62d83dd9f3fc7dc373e9cfa |
File details
Details for the file hashfile-2.1.5-py2.py3-none-any.whl
.
File metadata
- Download URL: hashfile-2.1.5-py2.py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b08f8c11b65354d55a2b66f748a989f91d2fb7d8c466948ff24f3ffa27b735a |
|
MD5 | 37705ceb81535283ae379ae7e49a348b |
|
BLAKE2b-256 | 4a312e1137330ea93e71902f4f38f6343ab24fb0fc8b283149586b63a66fa67a |