Return MD5 Checksum
1534
def md5(source):
    
    # fix passing char '+' from source
    source = source.replace("%2B", "+")
    with open(source) as file_to_check:
        data = file_to_check.read()
        return hashlib.md5(data).hexdigest()
739902
def compare_checksums(self):
        
        is_match = True
        reference_checksums = self.parse_checksum_file(
            self.files['checksum']['file'])
        for md5, file in reference_checksums.items():
            if os.path.isfile('/'.join((self.rawdir, file))):
                if self.get_file_md5(self.rawdir, file) != md5:
                    is_match = False
                    LOG.warning('%s was not downloaded completely', file)
                    return is_match

        return is_match
578245
def md5(self):
        
        result = str(self._updated) + str(self.base_frame)
        return result
1068747
def md5(self):
        """"""
        return hashlib.md5('_'.join([self.CHROM, str(self.POS), self.REF,
                                     self.ALT])).hexdigest()
1289658
def calculate_file_md5(filepath, blocksize=2 ** 20):
    """"""
    checksum = hashlib.md5()

    with click.open_file(filepath, "rb") as f:

        def update_chunk():
            """Add chunk to checksum."""
            buf = f.read(blocksize)
            if buf:
                checksum.update(buf)
            return bool(buf)

        while update_chunk():
            pass

    return checksum.hexdigest()
1157387
def calculate_checksum(file)
      @lookup_checksums[file] = Digest::MD5.hexdigest(File.read(file, mode: "rb")) rescue ""
    end
684625
def get_checksum(self, encoder=base64.b64encode, hasher=hashlib.sha256):
        """"""
        assert self._closed, "Archive not closed"
        with open(self._temp_archive_file.name, 'rb') as fh:
            return encoder(checksum(fh, hasher())).decode('ascii')
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()
464770
def calculate_md5(fileobject, size=2**16):
    """"""
    fileobject.seek(0)
    md5 = hashlib.md5()
    for data in iter(lambda: fileobject.read(size), b''):
        if not data: break
        if isinstance(data, six.text_type):
            data = data.encode('utf-8') # md5 needs a byte string
        md5.update(data)
    fileobject.seek(0) # rewind read head
    return md5.hexdigest()
1207927
def compare_md5(self):
        """"""
        if self.direction == "put":
            remote_md5 = self.remote_md5()
            return self.source_md5 == remote_md5
        elif self.direction == "get":
            local_md5 = self.file_md5(self.dest_file)
            return self.source_md5 == local_md5
240214
def check_md5(filename, stored_md5):
    
    computed_md5 = _get_file_md5(filename)
    if stored_md5 != computed_md5:
        print ("MD5 checksum of filename", filename,
               "failed. Expected MD5 was", stored_md5,
               "but computed MD5 was", computed_md5, '\n',
               "Please check if the data has been downloaded correctly or if the upstream data has changed.")
630806
def file_checksum(fname):
    
    size = os.path.getsize(fname)
    with open(fname, "r+") as f:
        checksum = hashlib.md5(mmap.mmap(f.fileno(), size)).hexdigest()
    return checksum
122065
def get_md5(self, filename):
        
        with open(filename, 'rb') as f:
            m = hashlib.md5(f.read())
        return m.hexdigest()
1063285
def md5sum( string ):
    
    h = hashlib.new( 'md5' )
    h.update( string.encode( 'utf-8' ) )
    return h.hexdigest()
444803
function getChecksum(fs, path, callback) {
  fs.readFile(path, function(err, data) {
    if(!err) {
      callback(null, md5sum(data));
    } else if(err.code === 'ENOENT') {
      // File does not exist so the checksum is an empty string
      callback(null, "");
    } else {
      callback(err);
    }
  });
}
335463
def md5_digest(instr):
    '''
    
    '''
    return salt.utils.stringutils.to_unicode(
        hashlib.md5(salt.utils.stringutils.to_bytes(instr)).hexdigest()
    )
583491
def fileMD5(filename, partial=True):
    ''' '''
    filesize = os.path.getsize(filename)
    # calculate md5 for specified file
    md5 = hash_md5()
    block_size = 2**20  # buffer of 1M
    try:
        # 2**24 = 16M
        if (not partial) or filesize < 2**24:
            with open(filename, 'rb') as f:
                while True:
                    data = f.read(block_size)
                    if not data:
                        break
                    md5.update(data)
        else:
            count = 16
            # otherwise, use the first and last 8M
            with open(filename, 'rb') as f:
                while True:
                    data = f.read(block_size)
                    count -= 1
                    if count == 8:
                        # 2**23 = 8M
                        f.seek(-2**23, 2)
                    if not data or count == 0:
                        break
                    md5.update(data)
    except IOError as e:
        sys.exit(f'Failed to read {filename}: {e}')
    return md5.hexdigest()