get the checksum content for a feature
167247
private Properties getChecksumsForMF(File mf) throws IOException {
        Properties props = new Properties();

        InputStream is = null;
        try {
            is = new FileInputStream(mf);
            Manifest manifest = ManifestProcessor.parseManifest(is);

            String fileName = manifest.getMainAttributes().getValue("Subsystem-SymbolicName");
            NameValuePair pair = ManifestHeaderProcessor.parseBundleSymbolicName(fileName);
            props.put("file.name", pair.getName());

            String contents = manifest.getMainAttributes().getValue("Subsystem-Content");

            Map<String, Map<String, String>> data = ManifestHeaderProcessor.parseImportString(contents);

            for (Map.Entry<String, Map<String, String>> entry : data.entrySet()) {

                String name = entry.getKey();
                Map<String, String> attrs = entry.getValue();
                String type = attrs.get("type");
                // exclude the feature type and jar type
                if (type != null && (type.equals("osgi.subsystem.feature") || type.equals("checksum"))) {
                    continue;
                }

                // find the jar, we don't need care about the version,
                // because only one jar exists when build
                String location = attrs.get("location:");
                File jarFile = null;

                String version = attrs.get("version");
                VersionRange range = new VersionRange(version == null ? "0" : version);
                jarFile = cblbr.selectBundle(location, name, range);

                if (jarFile == null && location != null) {
                    jarFile = new File(installRoot, location);
                }

                if (jarFile == null && (type == null || "osgi.bundle".equals(type))) {
                    throw new BuildException("The OSGi Bundle with name: " + name + ", location: " + location + ", and version " + version
                                             + " does not exist (included in manifest "
                                             + mf.getName() + ")");
                }

                // If we have a null jar, throw a helpful exception rather than an NPE on the next line
                if (jarFile == null)
                {
                    throw new IllegalArgumentException("Could not find a jar file for the bundle " + name);
                }

                if (!jarFile.exists()) {
                    if ((type == null || "osgi.bundle".equals(type))) {
                        throw new BuildException("The OSGi Bundle with: " + name + ", location: " + location + ", and version " + version
                                                 + " does not exist (included in manifest "
                                                 + mf.getName() + ". The jar name was calculated as " + jarFile.getAbsolutePath() + " but this file does not exist.)");
                    }
                } else {
                    // If the bundle selection gave us a directory, and we're here, something is wrong
                    // We can't - and don't want to - try and calculate an MD5 hash for a directory
                    if (jarFile.isDirectory()) {
                        throw new BuildException("The entry with name " + name + ", location " + location + ", and version range " + version + " does not exist from "
                                                 + mf.getName());
                    }
                    if (shouldGenerateChecksum(jarFile)) {
                        // if it's not a directory, carry on and calculate the jar checksum
                        String[] checksumPair = getChecksumPair(jarFile);
                        props.setProperty(checksumPair[0], checksumPair[1]);
                    }
                }

            }
        } finally {
            FileUtils.tryToClose(is);
        }
        return props;

    }
751261
def get_content_hash(self):
        
        if not self.rexists():
            return SCons.Util.MD5signature('')
        fname = self.rfile().get_abspath()
        try:
            cs = SCons.Util.MD5filesignature(fname,
                chunksize=SCons.Node.FS.File.md5_chunksize*1024)
        except EnvironmentError as e:
            if not e.filename:
                e.filename = fname
            raise
        return cs
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
502631
def format_checksum(checksum_pyxb):
    
    return '{}/{}'.format(
        checksum_pyxb.algorithm.upper().replace('-', ''), checksum_pyxb.value().lower()
    )
1299685
public static String getChecksum(InputStream is, String algorithm) throws IOException {

		if (algorithm.equals(JawrConstant.CRC32_ALGORITHM)) {
			return getCRC32Checksum(is);
		} else if (algorithm.equals(JawrConstant.MD5_ALGORITHM)) {
			return getMD5Checksum(is);
		} else {
			throw new BundlingProcessException("The checksum algorithm '" + algorithm + "' is not supported.\n"
					+ "The only supported algorithm are 'CRC32' or 'MD5'.");
		}
	}
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()
684204
def action_verify_checksum(self, ids):
        """"""
        try:
            count = 0
            for file_id in ids:
                f = FileInstance.query.filter_by(
                    id=uuid.UUID(file_id)).one_or_none()
                if f is None:
                    raise ValueError(_("Cannot find file instance."))
                verify_checksum.delay(file_id)
                count += 1
            if count > 0:
                flash(_('Fixity check(s) sent to queue.'), 'success')
        except Exception as exc:
            if not self.handle_view_exception(exc):
                raise
            current_app.logger.exception(str(exc))  # pragma: no cover
            flash(_('Failed to run fixity checks.'),
                  'error')
755037
function verifyChecksum(fileName, checksum) {
  return kew.resolve(hasha.fromFile(fileName, {algorithm: 'sha256'})).then(function (hash) {
    var result = checksum == hash
    if (result) {
      console.log('Verified checksum of previously downloaded file')
    } else {
      console.log('Checksum did not match')
    }
    return result
  }).fail(function (err) {
    console.error('Failed to verify checksum: ', err)
    return false
  })
}
1044663
def calculate_checksum(self):
        
        checksum = ESPLoader.ESP_CHECKSUM_MAGIC
        for seg in self.segments:
            if seg.include_in_checksum:
                checksum = ESPLoader.checksum(seg.data, checksum)
        return checksum
1290704
def parse_checksums(checksums_string):
    """"""
    checksums_list = []
    for line in checksums_string.split('\n'):
        try:
            # skip empty lines
            if line == '':
                continue

            checksum, filename = line.split()
            # strip leading ./
            if filename.startswith('./'):
                filename = filename[2:]
            checksums_list.append({'checksum': checksum, 'file': filename})
        except ValueError:
            logging.debug('Skipping over unexpected checksum line %r', line)
            continue

    return checksums_list
954245
def compute_checksum(line):
    """"""
    return sum((int(c) if c.isdigit() else c == '-') for c in line[0:68]) % 10
1080172
def checksum(self, chunk_size=None, progress_callback=None, **kwargs):
        """"""
        fp = self.open(mode='rb')
        try:
            value = self._compute_checksum(
                fp, size=self._size, chunk_size=None,
                progress_callback=progress_callback)
        except StorageError:
            raise
        finally:
            fp.close()
        return value
225528
function validateChecksum(requester, params) {
        params = params || {
            filePath: installerPath,
            expectedChecksum: _updateParams.checksum
        };

        var hash = crypto.createHash('sha256'),
            currentRequester = requester || "";

        if (fs.existsSync(params.filePath)) {
            var stream = fs.createReadStream(params.filePath);

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

            stream.on('end', function () {
                var calculatedChecksum = hash.digest('hex'),
                    isValidChecksum = (params.expectedChecksum === calculatedChecksum),
                    status;

                if (isValidChecksum) {
                    if (process.platform === "darwin") {
                        status = {
                            valid: true,
                            installerPath: installerPath,
                            logFilePath: logFilePath,
                            installStatusFilePath: installStatusFilePath
                        };
                    } else if (process.platform === "win32") {
                        status = {
                            valid: true,
                            installerPath: quoteAndConvert(installerPath, true),
                            logFilePath: quoteAndConvert(logFilePath, true),
                            installStatusFilePath: installStatusFilePath
                        };
                    }
                } else {
                    status = {
                        valid: false,
                        err: nodeErrorMessages.CHECKSUM_DID_NOT_MATCH
                    };
                }
                postMessageToBrackets(MessageIds.NOTIFY_VALIDATION_STATUS, currentRequester, status);
            });
        } else {
            var status = {
                valid: false,
                err: nodeErrorMessages.INSTALLER_NOT_FOUND
            };
            postMessageToBrackets(MessageIds.NOTIFY_VALIDATION_STATUS, currentRequester, status);
        }
    }
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')
826040
def calc_checksum(self, data):
        

        output = 0
        length = len(data)
        for value in data:
            output += int(value, 16)

        output += length
        checksum = hex(output & int('0x007F', 16)).lstrip("0x")
        data.append(checksum)
        data.append('F7')
        return data
1103653
function computeChecksum(filename) {
	var contents = fs.readFileSync(filename);

	var hash = crypto
		.createHash('md5')
		.update(contents)
		.digest('base64')
		.replace(/=+$/, '');

	return hash;
}
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());
        }
    }