def unique_hash(filepath, blocksize=(2 ** 20)):
 s = sha1()
 with open(filepath, 'rb') as f:
  while True:
   buf = f.read(blocksize)
   if (not buf):
    break
   s.update(buf)
 return s.hexdigest().upper()

def unique_hash ( filepath , blocksize = ( 2 ** 20 ) ) : s = sha1 ( ) with open ( filepath , 'rb' ) as f : while True : buf = f . read ( blocksize ) if ( not buf ) : break s . update ( buf ) return s . hexdigest ( ) . upper ( )
small function to generate a hash to uniquely generate a file .