def checksum ( path ) : hasher = hashlib . sha1 ( ) with open ( path , 'rb' ) as stream : buf = stream . read ( BLOCKSIZE ) while len ( buf ) > 0 : hasher . update ( buf ) buf = stream . read ( BLOCKSIZE ) return hasher . hexdigest ( )
generating a checksum of a file python
Calculcate checksum for a file .
def checksum(path):
    """Calculcate checksum for a file."""
    hasher = hashlib.sha1()
    with open(path, 'rb') as stream:
        buf = stream.read(BLOCKSIZE)
        while len(buf) > 0:
            hasher.update(buf)
            buf = stream.read(BLOCKSIZE)
    return hasher.hexdigest()