Files
Artemis/spec_files/__get_hash_code.py
Alessandro 8e79bf6adf Fix a bug in the *.spec files and also apply the following major changes:
- Add support for adding the base folder to PATH.
- Only display one pop up window at a time in order to avoid confusion.
- Add automatic updates feature:
	- Windows and Linux versions will be shipped with an updater program used to
	  update both Artemis and the updater itself.
	- MacOs versions will not have the updater. Instead the user will be asked
	  to download the new software version (if present) via browser.
2019-10-15 19:14:29 +02:00

32 lines
645 B
Python

import hashlib
import sys
"""Print on stadard output the size in KB and sha256 codes of a list
of command line-provided file names."""
print()
try:
fnames = sys.argv[1:]
except Exception:
print("Provide a valid filename.")
exit()
for fname in fnames:
try:
with open(fname, mode='rb') as f:
target = f.read()
except Exception:
print("File not found")
exit()
code = hashlib.sha256()
code.update(target)
hash_code = code.hexdigest()
print("File name:", fname)
print("Size (KB):", round(len(target) / 1024, 3))
print("Hash code:", hash_code)
print("-" * 80)