Get the checksum of a file.
@param src The file path
@return The checksum
@see DistributedFileSystem#getFileChecksum(Path)
765539
MD5MD5CRC32FileChecksum getFileChecksum(String src) throws IOException {
    checkOpen();
    return getFileChecksum(dataTransferVersion,
        src, namenode, namenodeProtocolProxy, socketFactory, socketTimeout);
  }
510201
def _checksum(in_file, block_size=65536):
    
    cs = hashlib.sha256()
    with open(in_file, "rb") as f:
        for block in iter(lambda: f.read(block_size), b''):
            cs.update(block)
    return cs.hexdigest()
731321
def compute_checksum(&block)
      crc = CRC.new
      # Have to read this first because it might change the seek position.
      file_size = header.file_size
      @io.seek(8, IO::SEEK_SET)
      pos = 8
      length = 4096-8
      buf = nil
      while true
        buf = @io.read(length, buf)
        break if !buf
        crc.update(buf)
        pos += buf.size
        block.call(pos) if block
        length = 4096
      end
      crc.crc
    end
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;

    }
190839
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()
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
67258
def get_checksum(self):
        '''
        
        '''
        if self._checksum:
            return self._checksum

        if not self._filename:
            raise RuntimeError('Source calc file is required in order to properly save the data!')

        calc_checksum = hashlib.sha224()
        struc_repr = ""
        for ase_obj in self.structures:
            struc_repr += "%3.6f %3.6f %3.6f %3.6f %3.6f %3.6f %3.6f %3.6f %3.6f " % tuple(map(abs, [ase_obj.cell[0][0], ase_obj.cell[0][1], ase_obj.cell[0][2], ase_obj.cell[1][0], ase_obj.cell[1][1], ase_obj.cell[1][2], ase_obj.cell[2][0], ase_obj.cell[2][1], ase_obj.cell[2][2]])) # NB beware of length & minus zeros

            for atom in ase_obj:
                struc_repr += "%s %3.6f %3.6f %3.6f " % tuple(map(abs, [chemical_symbols.index(atom.symbol), atom.x, atom.y, atom.z])) # NB beware of length & minus zeros

        if self.info["energy"] is None:
            energy = str(None)
        else:
            energy = str(round(self.info['energy'], 11 - int(math.log10(math.fabs(self.info['energy'])))))

        calc_checksum.update((
            struc_repr + "\n" +
            energy + "\n" +
            self.info['prog'] + "\n" +
            str(self.info['input']) + "\n" +
            str(sum([2**x for x in self.info['calctypes']]))
        ).encode('ascii')) # NB this is fixed and should not be changed

        result = base64.b32encode(calc_checksum.digest()).decode('ascii')
        result = result[:result.index('=')] + 'CI'
        return result
170489
function _checksums(dir) {
  const checksums = {};

  glob.sync(resolve(dir, '**/!(*.pack.+(s[ac]ss|js))'), { mark: true }).forEach((file) => {
    if (Utils.endsWith(file, '/')) { return; }

    const relativePath = relative(dir, file);
    checksums[relativePath] = Utils.checksum(file);
  });

  return checksums;
}
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'.");
		}
	}
374691
Block[] getFileBlocks(String src) {
    waitForReady();
    byte[][] components = INodeDirectory.getPathComponents(src);
    readLock();
    try {
      INode targetNode = rootDir.getNode(components);
      if (targetNode == null)
        return null;
      if(targetNode.isDirectory())
        return null;
      return ((INodeFile)targetNode).getBlocks();
    } finally {
      readUnlock();
    }
  }
1231028
private static String calculateChecksum(String string) {
        byte[] bytes = string.getBytes(UTF_8);
        Checksum checksum = new CRC32();
        checksum.update(bytes, 0, bytes.length);
        return Long.toHexString(checksum.getValue()).toUpperCase();
    }
52637
def checksum(path, hashfunc='md5'):
    
    import checksumdir
    hash_func = checksumdir.HASH_FUNCS.get(hashfunc)
    if not hash_func:
        raise NotImplementedError('{} not implemented.'.format(hashfunc))

    if os.path.isdir(path):
        return checksumdir.dirhash(path, hashfunc=hashfunc)

    hashvalues = []
    path_list = glob.glob(path)
    logger.debug("path_list " + str(path_list))
    for path in path_list:
        if os.path.isfile(path):
            hashvalues.append(checksumdir._filehash(path, hashfunc=hash_func))
    logger.debug(str(hashvalues))
    hash = checksumdir._reduce_hash(hashvalues, hashfunc=hash_func)
    return hash
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
1362922
@Override
    protected List<ChecksumFile> getFilesToProcess()
    {
        List<ChecksumFile> files = new LinkedList<ChecksumFile>();

        @SuppressWarnings("unchecked")
        Set<Artifact> artifacts = transitive ?  project.getArtifacts() : project.getDependencyArtifacts();
        for ( Artifact artifact : artifacts )
        {
            if ( ( scopes == null || scopes.contains( artifact.getScope() ) ) && ( types == null || types.contains(
                artifact.getType() ) ) )
            {
                files.add( new ChecksumFile( "", artifact.getFile(), artifact.getType(), artifact.getClassifier() ) );
            }
        }

        return files;
    }
123402
public FileStatus[] getListing(String src) throws IOException {
    getListingCheck(src);
    FileStatus[] stats =  dir.getListing(src);
    if (auditLog.isInfoEnabled()) {
      logAuditEvent(getCurrentUGI(),
        Server.getRemoteIp(),
        "listStatus", src, null, null);
    }
    return stats;
  }
99376
private byte[] getChecksum(byte[] bytes) throws NoSuchProviderException, NoSuchAlgorithmException {
        byte[] d = cryptography().sha512(bytes);
        return new byte[]{d[0], d[1], d[2], d[3]};
    }
862769
def file_checksum(filepath):
    
    checksum = hashlib.md5()
    with open(filepath, 'rb') as f:
        for fragment in iter(lambda: f.read(65536), ''):
            checksum.update(fragment)
    return checksum.hexdigest()