Q:

Program to Find Hash of File | Python

0

Program to Find Hash of File | Python

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import hashlib

def hash_file(filename):
   
   h = hashlib.sha1()

   with open(filename,'rb') as file:


       chunk = 0
       while chunk != b'':

           chunk = file.read(512)
           h.update(chunk)


   return h.hexdigest()

message = hash_file("track1.mp3")
print(message)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now