Create the md5 hash of a file using the hashlib library.
186863
def create_md5(path):
    """"""
    m = hashlib.md5()
    # rb necessary to run correctly in windows.
    with open(path, "rb") as f:
        while True:
            data = f.read(8192)
            if not data:
                break
            m.update(data)

    return m.hexdigest()
691696
def md5_of_file(abspath):
    
    chunk_size = 1024 * 1024
    m = hashlib.md5()
    with open(abspath, "rb") as f:
        while True:
            data = f.read(chunk_size)
            if not data:
                break
            m.update(data)
    return m.hexdigest()
290208
function hashFile(filename, callback) {

    var calledBack = false,
        md5sum = crypto.createHash('md5'),
        stream = fs.ReadStream(filename);

    stream.on('data', function (data) {
      md5sum.update(data);
    });

    stream.on('end', function () {
      var hash = md5sum.digest('hex');
      callback(null, hash);
    });

    stream.on('error', function(err) {
      handleResponse(err);
    });

    function handleResponse(err, hash) {
      if (calledBack) {
        return;
      }

      calledBack = true;
      callback(err, hash);
    }
  }
1369560
def file_md5(f, size=8192):
    ""
    md5 = hashlib.md5()
    while True:
        data = f.read(size)
        if not data:
            break
        md5.update(data)
    return md5.hexdigest()
229616
def _create_md5_dict(self):
        
        self.sbo_md5 = {}
        md5_lists = SBoGrep(self.prgnam).checksum()
        for src, md5 in zip(self.sources, md5_lists):
            self.sbo_md5[src] = md5
272589
async function hash (file) {
  const filesize = await fileUtil.getFileSize(file)

  const chunkSize = 64 * 1024

  const firstBytesPromise = fileUtil.readBytes({
    file,
    chunkSize,
    start: 0
  })

  const lastBytesPromise = fileUtil.readBytes({
    file,
    chunkSize,
    start: filesize - chunkSize
  })

  const [ firstBytes, lastBytes ] = await Promise.all([firstBytesPromise, lastBytesPromise])

  return crypto
    .createHash('md5')
    .update(firstBytes)
    .update(lastBytes)
    .digest('hex')
}
298407
def hash(filepath, method='sha1', buffer_size=65536):
    
    if method == 'sha1':
        hash_function = hashlib.sha1()
    elif method == 'md5':
        hash_function = hashlib.md5()
    else:
        raise NotImplementedError('Only md5 and sha1 hashes are known, but '
                                  ' \'{}\' was specified.'.format(method))

    with open(filepath, 'rb') as fp:
        while True:
            data = fp.read(buffer_size)
            if not data:
                break
            hash_function.update(data)
    return hash_function.hexdigest()
293838
def get_multipart_md5(self, filename, chunk_size=8 * 1024 * 1024):
        
        # Loop through the file contents ...
        md5s = []
        with open(filename, 'rb') as fp:
            while True:
                # Break it into chunks
                data = fp.read(chunk_size)
                # Finish when there are no more
                if not data:
                    break
                # Generate a md5 hash for each chunk
                md5s.append(hashlib.md5(data))

        # Combine the chunks
        digests = b"".join(m.digest() for m in md5s)

        # Generate a new hash using them
        new_md5 = hashlib.md5(digests)

        # Create the ETag as Amazon will
        new_etag = '"%s-%s"' % (new_md5.hexdigest(), len(md5s))

        # Trim it down and pass it back for comparison
        return new_etag.strip('"').strip("'")
308846
def _md5_file(fn, block_size=1048576):
    
    h = hashlib.md5()
    with open(fn) as fp:
        d = 1
        while d:
            d = fp.read(block_size)
            h.update(d)
    return h.hexdigest()
411059
def _md5_compute(self, f):
        '''
        
        '''
        md5 = hashlib.md5()
        block_size = 16384
        f.seek(0, 2)
        remaining = f.tell()
        f.seek(0)

        while (remaining > block_size):
            data = f.read(block_size)
            remaining = remaining - block_size
            md5.update(data)

        if remaining > 0:
            data = f.read(remaining)
            md5.update(data)

        return md5.digest()
1072063
def md5sum(filen):
    '''
    '''
    with open(filen, 'rb') as fileh:
        md5 = hashlib.md5(fileh.read())

    return md5.hexdigest()
213303
function digestFile(file, algorithm, encoding) {
    return crypto.createHash(algorithm || 'md5').update(fs.readFileSync(file)).digest(encoding || 'hex');
}
913759
def hash_file(file_obj,
              hash_function=hashlib.md5):
    
    # before we read the file data save the current position
    # in the file (which is probably 0)
    file_position = file_obj.tell()
    # create an instance of the hash object
    hasher = hash_function()
    # read all data from the file into the hasher
    hasher.update(file_obj.read())
    # get a hex version of the result
    hashed = hasher.hexdigest()
    # return the file object to its original position
    file_obj.seek(file_position)

    return hashed
298184
def md5_string(s):
    
    m = hashlib.md5()
    m.update(s)
    return str(m.hexdigest())
1370579
def md5sum(filename, blocksize=8192):
        """"""
        with open(filename, 'rb') as fh:
            m = hashlib.md5()
            while True:
                data = fh.read(blocksize)
                if not data:
                    break
                m.update(data)
        return m.hexdigest()
1271036
def _hash_of_file(path, algorithm):
    """"""
    with open(path, 'rb') as archive:
        hash = hashlib.new(algorithm)
        for chunk in read_chunks(archive):
            hash.update(chunk)
    return hash.hexdigest()
136171
def _gen_md5_filehash(fname, *args):
    '''
    
    '''
    _hash = hashlib.md5()
    with salt.utils.files.fopen(fname, 'rb') as f:
        for chunk in iter(lambda: f.read(4096), b''):
            _hash.update(chunk)

    for extra_arg in args:
        _hash.update(six.b(str(extra_arg)))
    return _hash.hexdigest()