Skip to main content

Calculates MD5 and SHA256 hashes for a given file or bytes

Project description

Description

Calculates MD5 and SHA256 hashes for a given file

Installation

pip install hash_calc

Usage

From command line:

python -m hash_calc [-h] --path PATH

Option Short Type Default Description
--path -p String - Path of the file to be hashed

Programmatically:

from hash_calc.HashCalc import HashCalc

# 1.) Hash a file
pathToFile = "/path/to/file/test.txt

hashCalc = HashCalc(pathToFile)

print(hashCalc.md5)
print(hashCalc.sha256)

# 2.) Hash bytes
h = HashCalc.fromBytes(b"\x01\x02\x03")

print(h.sha256)
print(h.md5)

Example

python -m hash_calc -p test.txt

Creates the follwing result:

##############################################################################################

Hash Calc by 5f0
Calculates MD5 and SHA256 hashes for a given file

Current working directory: /path/to/hash_calc
        Investigated file: test.txt

                 MD5 Hash: 265e08df10ed62d756e5e0bb6fadd69c
              SHA256 Hash: 1675aa3766017a42980e686132eff094ba789bc3dc44de3e53f2fb05a7a513ff

                 Datetime: 01/01/1970 10:20:30

##############################################################################################

Execution Time: 0.003022 sec

License

MIT

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

hash_calc-1.1.0.tar.gz (3.6 kB view hashes)

Uploaded Source

Built Distribution

hash_calc-1.1.0-py3-none-any.whl (4.5 kB view hashes)

Uploaded Python 3

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