-
Notifications
You must be signed in to change notification settings - Fork 0
/
file_hash_check.py
41 lines (31 loc) · 1.3 KB
/
file_hash_check.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Hash Checker!
Enter the full path of the file at the prompt. Example output:
Welcome to My Hash Checker!
Enter the filename (current directory) or full path of the file to check: c3745-adventerprisek9-mz.124-25d.bin
The hashes for c3745-adventerprisek9-mz.124-25d.bin are:
- MD5: 563797308a3036337c3dee9b4ab54649
- SHA1: a1e583a54843802520cbe0c47bddf8b6ebd0118c
- SHA256: 158ec1c7a6bc5895a5d3408629dac1609304df76e3f35daea3241e116e9db5d4
Script complete. Have a nice day.
Project: Automation
"""
from __future__ import print_function
import hashlib
def main(filename):
"""Application entry point.
:param str filename: The file to be hashed.
:returns: None
:rtype: None
"""
print("The hashes for {0} are:".format(filename))
print("- MD5: {0}".format(hashlib.md5(open(filename, 'rb').read()).hexdigest()))
print("- SHA1: {0}".format(hashlib.sha1(open(filename, 'rb').read()).hexdigest()))
print("- SHA256: {0}\n".format(hashlib.sha256(open(filename, 'rb').read()).hexdigest()))
if __name__ == "__main__":
print("Welcome to the File Hash Checker!\n")
file_to_hash = input(
"Enter the filename (current directory) or full path of the file to check: ")
main(file_to_hash)
print("Script complete. Have a nice day.")