Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2@file
3@brief Reasonably inefficient functions about files.
4"""
5import hashlib
8def checksum_md5(filename):
9 """computes MD5 for a file
10 @param filename filename
11 @return string or None if there was an error
12 """
13 fname = filename
14 block_size = 0x10000
16 fd = open(fname, "rb")
17 try:
18 block = [fd.read(block_size)]
19 while len(block[-1]) > 0:
20 block.append(fd.read(block_size))
21 contents = block
22 zero = hashlib.md5()
23 i = 0
24 for el in contents:
25 i += 1
26 zero.update(el)
27 m = zero
28 return m.hexdigest()
29 finally:
30 fd.close()
31 return None