Grab the checksum file for a given entry.
549170
def grab_checksums_file(entry):
    """"""
    http_url = convert_ftp_url(entry['ftp_path'])
    full_url = '{}/md5checksums.txt'.format(http_url)
    req = requests.get(full_url)
    return req.text
723851
def fileupdate(self, data):
        """"""

        self.name = data["name"]
        add = self.__additional
        add["filetype"] = "other"
        for filetype in ("book", "image", "video", "audio", "archive"):
            if filetype in data:
                add["filetype"] = filetype
                break
        if add["filetype"] in ("image", "video", "audio"):
            add["thumb"] = data.get("thumb", dict())
        # checksum is md5
        add["checksum"] = data["checksum"]
        add["expire_time"] = data["expires"] / 1000
        add["size"] = data["size"]
        add["info"] = data.get(add["filetype"], dict())
        add["uploader"] = data["user"]
        if self.room.admin:
            add["info"].update({"room": data.get("room")})
            add["info"].update({"uploader_ip": data.get("uploader_ip")})
        self.updated = True
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);
    }
  });
}
513883
private String getChunkChecksum(File chunkFile) {
        try {
            return checksumUtil.generateChecksum(chunkFile);
        } catch (IOException e) {
            throw new DuraCloudRuntimeException("Unable to generate checksum for file " +
                                                chunkFile + " due to: " + e.getMessage());
        }
    }
255398
def get_file_checksum(self, path, **kwargs):
        
        metadata_response = self._get(
            path, 'GETFILECHECKSUM', expected_status=httplib.TEMPORARY_REDIRECT, **kwargs)
        assert not metadata_response.content
        data_response = self._requests_session.get(
            metadata_response.headers['location'], **self._requests_kwargs)
        _check_response(data_response)
        return FileChecksum(**_json(data_response)['FileChecksum'])
501946
def _get_checksum(path):
    

    # md5 uses a 512-bit digest blocks, let's scale by defined block_size
    _md5 = hashlib.md5()
    chunk_size = 128 * _md5.block_size

    try:
        with open(path, 'rb') as _file:
            for chunk in iter(lambda: _file.read(chunk_size), ''):
                _md5.update(chunk)
        return _md5.hexdigest()

    except IOError:
        return None
748719
def old_checksum(self):
        """"""
        if self.context.is_file(self.checksum_file):
            logger.debug("Reading saved checksum from %s ..", format_path(self.checksum_file))
            checksum = self.context.read_file(self.checksum_file).decode('ascii')
            logger.debug("Saved checksum is %s.", checksum)
            return checksum
1045645
def compare_checksum(info, f):
    
    pieces = info['pieces']

    def getchunks(f, size):
        while True:
            chunk = f.read(size)
            if chunk == '':
                break
            yield hashlib.sha1(chunk).digest()

    calc = getchunks(f, info['piece length'])
    ref = (pieces[i:i + 20] for i in xrange(0, len(pieces), 20))
    for expected, actual in itertools.izip(calc, ref):
        if expected != actual:
            return False
    return ensure_empty(calc) and ensure_empty(ref)
1281777
def checksum(self, path, hashtype='sha1'):
        """"""
        return self._handler.checksum(hashtype, posix_path(path))
640464
public static Checksum checksum(File file, Checksum checksum) throws IORuntimeException {
		Assert.notNull(file, "File is null !");
		if (file.isDirectory()) {
			throw new IllegalArgumentException("Checksums can't be computed on directories");
		}
		try {
			return IoUtil.checksum(new FileInputStream(file), checksum);
		} catch (FileNotFoundException e) {
			throw new IORuntimeException(e);
		}
	}
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')
669432
def new_checksum(self):
        """"""
        if self.context.is_file(self.filename):
            friendly_name = format_path(self.filename)
            logger.debug("Calculating SHA1 of %s ..", friendly_name)
            context = hashlib.sha1()
            context.update(self.context.read_file(self.filename))
            checksum = context.hexdigest()
            logger.debug("The SHA1 digest of %s is %s.", friendly_name, checksum)
            return checksum
818807
def get_checksum(self):
        
        arr = [ ]
        for elem in self.parsed:
            s = elem_checksum(elem)
            if s:
                arr.append(s)
        arr.sort()
        #print arr
        return md5(json.dumps(arr))
1030498
def md5_checksum(file_path, chunk_bytes=4194304):
    """"""

    with open(file_path, "rb") as infile:
        checksum = hashlib.md5()
        while 1:
            data = infile.read(chunk_bytes)
            if not data:
                break
            checksum.update(data)

    return checksum.hexdigest()
836304
def get_checksum_by_target(self, target):
        
        for csum in self.checksums:
            if csum.target == target:
                return csum
        return None
227579
def hash_prefix_list_checksum(self, threat_list):
        """"""
        q = '''SELECT value FROM hash_prefix
                WHERE threat_type=? AND platform_type=? AND threat_entry_type=?
                ORDER BY value
        '''
        params = [threat_list.threat_type, threat_list.platform_type, threat_list.threat_entry_type]
        with self.get_cursor() as dbc:
            dbc.execute(q, params)
            all_hashes = b''.join(bytes(h[0]) for h in dbc.fetchall())
            checksum = hashlib.sha256(all_hashes).digest()
        return checksum
842639
def get_data_checksum(proc_input, proc_slug, proc_version):
    """"""
    checksum = hashlib.sha256()
    checksum.update(json.dumps(proc_input, sort_keys=True).encode('utf-8'))
    checksum.update(proc_slug.encode('utf-8'))
    checksum.update(str(proc_version).encode('utf-8'))
    return checksum.hexdigest()