Please use the script to get the MD5 and SHA1 Hash value to identify content of the specific file
Useful at:
to verify the file whether completely transferred or not
to verify the file after downloading from the internet if they have given MD5 or SHA1
to compare with other files
## to get MD5 and SHA1 checksum value
import hashlib
BLOCKSIZE = 65536
hasher = hashlib.md5()
File = 'C:\\Users\\Administrator\\Downloads\\c4_agent.msi' ## you can change your path here...
print 'given file: {}'.format(File)
with open(File, 'rb') as afile:
buf = afile.read(BLOCKSIZE)
while len(buf) > 0:
hasher.update(buf)
buf = afile.read(BLOCKSIZE)
print 'MD5 checksum: {}'.format(hasher.hexdigest())
hasher = hashlib.sha1()
with open(File, 'rb') as afile:
buf = afile.read(BLOCKSIZE)
while len(buf) > 0:
hasher.update(buf)
buf = afile.read(BLOCKSIZE)
print 'SHA1 checksum: {}'.format(hasher.hexdigest())
'''
usage:
to verify the file whether completely transfered or not
to verify the file after download from internet if they given MD5 or SHA1
to compare files
'''
Sample Output: