Hashit an hashing application
This project is maintained by cjavad
Hashit takes arguments like this:
usage: hashit [-h] [-p] [-V] [-L] [-hl] [-H hashname]
[-e excludes [excludes ...]] [-C] [-sp] [-A] [-q] [-m] [-r]
[-s [string]] [-d [hash]] [-l list] [-cl list list]
[-c filename] [-o filename] [-S] [-sfv] [-bsd] [--dry-run]
[--trace] [--strict]
[path] [files [files ...]]
Where the options are at following:
Hashit is an hashing program which can be uses to hash and verify muliple
files on a system. I got the idea from an ubuntu iso image which have this
hash table, so i got the idea to make such a program using python.
positional arguments:
path
files
help:
-h, --help show this help message and exit
-p, --page Launch interactive help with python help() (for python
api)
-V, --version Print current version and exit
-L, --license Print license and exit
-hl, --hash-list Prints list of all supported hashes and exits
formats:
-S, --size Adds the file size to the output
-sfv, --sfv Outputs in a sfv compatible format
-bsd, --bsd output using the bsd checksum-format
settings:
-H hashname, --hash hashname
Select hash use -hl --hash-list for more info
-e excludes [excludes ...], --exclude excludes [excludes ...]
list of files and directories to exclude
-C, --color Enable colored output where it is supported
-sp, --strip-path Strips fullpath from the results
-A, --append Instead of writing to a file you will append to it
-q, --quiet Reduces output, (silences warnings)
-m, --memory-optimatation
Enables memory optimatation (useful for large files)
-r, --recursive Hash all files in all subdirectories
other:
-s [string], --string [string]
hash a string or a piece of text
-d [hash], --detect [hash]
Enable hash detection for check
-l list, --list list Takes a file (list) of strings and hashes each of them
-cl list list, --check-list list list
Takes two arguments, hashlist and stringlist
-c filename, --check filename
Verify checksums from a checksum file
-o filename, --output filename
output output to an output (file)
devtools:
--dry-run prints the list of files that is doing to be hashed
(and how) and the output type
--trace Print traceback of any error cathed and exit
--strict Exit non-zero on any errors
MIT, Copyrigth (c) 2017-2020 Javad Shafique
So if i want to hash a file called fx. icon.png in the img dir
$ hashit icon.png
eade8f2bb7fcb89d396a850b977740fd img/icon.png
Or i wanted to hash the tests directory with lets say blake2s and write it to a file using the bsd format and then verify it
$ hashit -H blake2s -o output.txt -bsd tests/
# no need to specify the files format it detects it automaticly
$ hashit -H blake2s -c output.txt -C # or --color for -C
tests/speed.py: OK
tests/test.py: OK
tests/__init__.py: OK
tests/speed2.py: OK
tests/res/benchmarks2.json: OK
tests/res/file.json: OK
tests/res/crc_hashcollisions.txt: OK
tests/res/benchmarks.json: OK
tests/res/pycrypto_vs_hashlib.json: OK
tests/__pycache__/speed.cpython-36.pyc: OK
tests/__pycache__/speed2.cpython-36.pyc: OK
tests/__pycache__/test.cpython-36.pyc: OK
tests/__pycache__/__init__.cpython-36.pyc: OK
But maybe you don’t want to hash an file but a password or a piece of text then use the -s option
$ hashit -s secret_key
73eeac3fa1a0ce48f381ca1e6d71f077
# if you just use -s it will read until you use ctrl+D (^D)
$ hashit -s
secret_key^D
73eeac3fa1a0ce48f381ca1e6d71f077
If you want to hash multiple files with forexample a wildcard(*):
$ hashit *.txt
d41d8cd98f00b204e9800998ecf8427e empty.txt
d41d8cd98f00b204e9800998ecf8427e another_0bytefile.txt
d41d8cd98f00b204e9800998ecf8427e no_data.txt
Fun fact the -l –list option can also be used if you really want to check an file, because it reads a file line by line can it be used for checking each and every line in any file like this:
Chances of hash collisions = 0% (JDK, haven’t done any statitics but technicly a lesser chances for bigger files (more lines more security!)
$ hashit -l LICENSE -o license.chk
$ hashit -cl license.chk LICENSE
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\: OK
©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©: OK
©-------------------------------------------------------------------------------©: OK
©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©: OK
MIT License : OK
: OK
Copyright (c) 2020 Javad Shafique: OK
: OK
Permission is hereby granted, free of charge, to any person obtaining a copy: OK
of this software and associated documentation files (the "Software"), to deal: OK
in the Software without restriction, including without limitation the rights: OK
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell: OK
copies of the Software, and to permit persons to whom the Software is: OK
furnished to do so, subject to the following conditions:: OK
: OK
The above copyright notice and this permission notice shall be included in all: OK
copies or substantial portions of the Software.: OK
: OK
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR: OK
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,: OK
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE: OK
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER: OK
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,: OK
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE: OK
SOFTWARE.: OK
: OK
NO ONE CAN CLAIM OWNERSHIP OF THIS "SOFTWARE" AND ASSOCIATED DOCUMENTATION FILES.: OK
: OK
Icon from freepik.com all rights reserved: OK
©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©: OK
©-------------------------------------------------------------------------------©: OK
TIP: add quotes around multi length strings to make them a single argument
It also got a python-level api for those you want to integrate this into your own application
from hashit import hashFile, new
# init hashing class
hasher = new("md5")
hash_from_file = hashFile("file.txt", hasher, True) # (True) Activate memory optimatation, faster for larger files
print(hash_from_file)
print(new("sha3_256", b'DATA').hexdigest())
print(new("crc32", b'DATA').hexdigest()) # custom hashes is also supported
See extra for more customization and extended api usage from python