/usr/lib/python3/dist-packages/cpl/md5sum.py is in python3-cpl 0.7.2-1build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import hashlib
def datamd5(hdulist):
'''Calculate the MD5SUM of all data regions of a HDUList.
'''
md5sum = hashlib.md5()
for hdu in hdulist:
if hdu.data is not None:
md5sum.update(bytes(hdu.data.data))
pad = b'\0' * (2880 - hdu.data.nbytes % 2880)
md5sum.update(pad)
return md5sum.hexdigest()
def verify_md5(hdulist):
return hdulist[0].header.get('DATAMD5') == datamd5(hdulist)
def update_md5(hdulist):
md5sum = datamd5(hdulist)
hdulist[0].header['DATAMD5'] = (md5sum, 'MD5 checksum')
return md5sum
|