/usr/lib/python2.7/dist-packages/cpl/md5sum.py is in python-cpl 0.6.2-4.
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 21 | import os
import hashlib
def datamd5(hdulist):
'''Calculate the MD5SUM of all data regions of a HDUList.
'''
sum = hashlib.md5()
for hdu in hdulist:
if hdu.data is not None:
sum.update(bytes(hdu.data.data))
pad = b'\0' * (2880 - hdu.data.nbytes % 2880)
sum.update(pad)
return sum.hexdigest()
def verify_md5(hdulist):
return hdulist[0].header.get('DATAMD5') == datamd5(hdulist)
def update_md5(hdulist):
sum = datamd5(hdulist)
hdulist[0].header.update('DATAMD5', sum, 'MD5 checksum')
return sum
|