A simple command line utility to generate hashes and verify if your files have been tampered with.
$ pip install -r requirements.txt
- Hashme mainly uses
argparse
andhashlib
, both of which are included already in Python3 standard library - pyfiglet is used for stylized description text on help
- pyperclip is used to copy text to clipboard
- CLI Mode:
- generates hash and display to console
- takes all inputs from command line; ouptuts verification result to command line
- copies hash to clipboard if
-c
flag is present
- Verifile Mode:
- generates hash using both (
md5
andsha256
) algorithms and saves to<filename>.verifile
in the current directory - takes input from
<filename>.verifile
that should exist in the current directory - verify against both (
md5
andsha256
) algorithms and outputs results to console
- generates hash using both (
- Verifolder Mode:
- generates hash for all files in a folder using
md5
algorithm and saves to<path>/verifolder/verifile.md5
(no folders) - uses well-known SFV file format compatible with most popular sfv tools
- takes
path
input from cli, it should be a valid path on filesystem - verifies all specified files and outputs results (
OK
,BAD
,MISSING
) to console for each file
- generates hash for all files in a folder using
- File(s) need to be in the same directory as the utility for cli and verifile modes.
- In folder mode, a folder named (
/verifolder
) is created inside target directory that will haveverifile.md5
for all files (not folders) in directory pointed to bypath
. - Two hashing algorithms are available: faster
MD5
and robustSHA256
.
$ hashme [-h] {cli,verifile,verifolder} ...
$ hashme cli [-h] [-a {md5,sha256}] [-v HASH] [-c] file #cli mode
$ hashme verifile [-h] [-v] file #verifile mode
$ hashme verifolder [-h] [-p PATH | -v] #verifolder mode
#generation
$ py hashme.py cli file #to generate hash, MD5 is default
$ py hashme.py cli -a algorithm file
$ py hashme.py cli -c file #generate hash and copy to clipboard
$ py hashme.py cli --clipboard file
# verification
$ py hashme.py cli -v hash file #to verify file against hash (assumed to be MD5 by default)
$ py hashme.py cli --hash hash file
$ py hashme.py cli -a algorithm -v hash file #explicitly specifying algorithm
$ py hashme.py cli --algo algorithm --hash hash file
# file mode
$ py hashme.py verifile file
$ py hashme.py verifile -v file
# folder mode
$ py hashme.py verifile "path"
$ py hashme.py verifile -v
Executable is generated with pyinstaller
.
$ pyinstaller --onefile "hashme.py"
#after pyfigment addition (fix for font not found issue)
$ pyinstaller --onefile --add-data "venv\Lib\site-packages\pyfiglet;./pyfiglet" hashme.py
Checkout latest release (.exe
) here.
- Hashing entire folder recursively
- Argparse Tutorial - YouTube
- https://docs.python.org/3/library/argparse.html
- https://docs.python.org/3/howto/argparse.html
- A Simple Guide To Command Line Arguments With ArgParse - towards data science
- http://pure-sfv.sourceforge.net/faqsfv.html#4.a
- Why not CRC32? -> can detect change; but not secure as making files having same hash is easier