FuzzkingCool Posted August 24, 2018 Report Share Posted August 24, 2018 Hiya, I have a need to recreate the file hash that the cm fileinfo command returns using python. Are you able to tell me about what type of hash this is? I can see it's base64 encoded I think? Is it only looking at the bits of the file, or also location , date, etc. ? Thanks!! - Aleks Link to comment Share on other sites More sharing options...
FuzzkingCool Posted August 24, 2018 Author Report Share Posted August 24, 2018 Ok, figured it out! import hashlib path = "/blah/blah/file.txt" md5 = hashlib.md5() BUF_SIZE = 65536 with open(path, 'rb') as f: while True: data = f.read(BUF_SIZE) if not data: break md5.update(data) print("MD5: {0}".format( md5.hexdigest().decode("hex").encode("base64")) ) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.