How do I calculate the MD5 checksum of a file contents in Python?
问题 the scenario is: I have generated md5 checksum for the pdf file which stored on the server using the following code: def createMd5Hash(self, file_path, pdf_title, pdf_author): md5_returned = None try: md5 = hashlib.md5() with open(file_path, 'rb') as file_to_check: for chunk in file_to_check: md5.update(chunk) md5_file = md5.hexdigest() custom_key = 'xyzkey-{}'.format(md5_file) md5.update(custom_key.encode()) md5_returned = md5.hexdigest() except Exception as e: print("Error while calculate