User Tools

Site Tools


python:index

This is an old revision of the document!


Python

md5sum in python

#
# md5sum.py
#
 
import sys
import hashlib 
 
 
if __name__ == '__main__': 
 
	for filename in sys.argv[1:] : 
		with open(filename, "rb" ) as file : 
			md5 = hashlib.md5() 
			chunksize = 65536 # 64k's
			content = file.read( chunksize )
			while content != b'' : 
				md5.update(content)
				content = file.read( chunksize )
 
			md5.digest()
			if len(sys.argv[1:]) > 1 : 
				print( f"{filename}: ", end ='' )
			print(md5.hexdigest())
@echo off
rem md5sum.cmd

python "md5sum.py" %*
python/index.1602140478.txt.gz · Last modified: 2022/12/02 22:02 (external edit)