Created
April 17, 2020 11:19
-
-
Save aluzed/4eacd73a6a9e4df37fdf3a09c334811b to your computer and use it in GitHub Desktop.
Get file checksum in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib, sys | |
if len(sys.argv) != 3: | |
print('Error must have 2 args : python get_hash.py <algo> <filename>') | |
exit(1) | |
algo = sys.argv[1] | |
filename = sys.argv[2] | |
func = getattr(hashlib, algo) | |
if func is not None: | |
print(func(open(filename, 'rb').read()).hexdigest()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment