get_file_md5
def get_file_md5(filename):
if not os.path.isfile(filename):
return
my_hash = hashlib.md5()
f = open(filename, 'rb')
while True:
b = f.read(8096) #set the buffer size for readig the data from file every time, can be set random value but always 9096, 8192
if not b: # if read all of the data, then break
break
my_hash.update(b) # set the str that need to be encrypted
f.close()
return my_hash.hexdigest() # Gets the encrypted hexadecimal string
references:
offlinerl/neorl