Read the md5 checksum stored alongside the given file, or null
if no md5 is stored.
@param dataFile the file containing data
@return the checksum stored in dataFile.md5
332880
public static MD5Hash readStoredMd5ForFile(File dataFile) throws IOException {
    File md5File = getDigestFileForFile(dataFile);

    String md5Line;
    
    if (!md5File.exists()) {
      return null;
    }
    
    BufferedReader reader =
      new BufferedReader(new FileReader(md5File));
    try {
      md5Line = reader.readLine();
      if (md5Line == null) { md5Line = ""; }
      md5Line = md5Line.trim();
    } catch (IOException ioe) {
      throw new IOException("Error reading md5 file at " + md5File, ioe);
    } finally {
      IOUtils.cleanup(LOG, reader);
    }
    
    Matcher matcher = LINE_REGEX.matcher(md5Line);
    if (!matcher.matches()) {
      throw new IOException("Invalid MD5 file at " + md5File
          + " (does not match expected pattern)");
    }
    String storedHash = matcher.group(1);
    File referencedFile = new File(matcher.group(2));

    // Sanity check: Make sure that the file referenced in the .md5 file at
    // least has the same name as the file we expect
    if (!referencedFile.getName().equals(dataFile.getName())) {
      throw new IOException(
          "MD5 file at " + md5File + " references file named " +
          referencedFile.getName() + " but we expected it to reference " +
          dataFile);
    }
    return new MD5Hash(storedHash);
  }
546233
public static void readAbbrList(String dataFile, Map map) throws IOException {
		BufferedReader fin = new BufferedReader(new FileReader(dataFile));
		
		String line;
		while ((line = fin.readLine()) != null) {
		    StringTokenizer strTok = new StringTokenizer(line, " \t\r\n");
		    
		    if (strTok.countTokens() <= 0) {
			continue;
		    } 
		    
		    String token = strTok.nextToken();
		    
		    map.put(token.toLowerCase(), token.toLowerCase());
		}
    }
997718
public static byte[] readBytesFromFile(File f) {
        byte[] bytes = null;
        try {
            int filesize = (int) f.length();
            bytes = new byte[filesize];
            DataInputStream in = new DataInputStream(new FileInputStream(f));
            in.readFully(bytes);
            in.close();
        } catch (Exception e) {
            System.out.println("Error reading byte[] from file: "
                    + e.getMessage());
            return null;
        }
        return bytes;
    }
741824
def _md5sum(file_path):
    
    md5 = hashlib.md5()

    with open(file_path, "rb") as md5_file:
        while True:
            data = md5_file.read(1024 * 1024 * 4)
            if not data:
                break
            md5.update(data)

    return md5.digest()
311919
public static String getFormatFromFlatFile(File flatFile) {
        if (flatFile == null || !flatFile.exists())
            return null;

        try (BufferedReader reader = new BufferedReader(createReader(flatFile))) {
            return getFormatFromFlatFileLine(reader.readLine());
        }
        catch (IOException e) {
            return null;
        }
    }
667220
public static byte[] md5FileToByte(File file) {
        if (file == null) return null;
        FileInputStream   fis               = null;
        DigestInputStream digestInputStream = null;
        try {
            fis = new FileInputStream(file);
            MessageDigest md = MessageDigest.getInstance("MD5");
            digestInputStream = new DigestInputStream(fis, md);
            byte[] buffer = new byte[256 * 1024];
            while (digestInputStream.read(buffer) > 0) ;
            md = digestInputStream.getMessageDigest();
            return md.digest();
        } catch (NoSuchAlgorithmException | IOException e) {
            e.printStackTrace();
            return null;
        } finally {
            IOKit.closeQuietly(fis);
            IOKit.closeQuietly(digestInputStream);
        }
    }
881196
public static String md5(byte[] source) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(source);
            byte tmp[] = md.digest();
            char str[] = new char[32];
            int k = 0;
            for (byte b : tmp) {
                str[k++] = hexDigits[b >>> 4 & 0xf];
                str[k++] = hexDigits[b & 0xf];
            }
            return new String(str);

        } catch (Exception e) {
            throw new IllegalArgumentException(e);
        }
    }
289363
public void readFrom(File keyFile) throws IOException, GeneralSecurityException {
        final String password = isPemEncrypted(keyFile)
                ? askForPasswd(keyFile.getCanonicalPath())
                : null
        ;
        privateKeys.add(loadKey(keyFile, password));
    }
420285
public static String fastMD5(File file)
    {        
        try (FileInputStream in = new FileInputStream(file))
        {            
            return calculateMD5Hash(in.getChannel());
        }
        catch (IOException e)
        {
            return null;
        }        
    }
783344
public static Schema getSchemaFromDataFile(Path dataFile, FileSystem fs) throws IOException {
    try (SeekableInput sin = new FsInput(dataFile, fs.getConf());
        DataFileReader<GenericRecord> reader = new DataFileReader<>(sin, new GenericDatumReader<GenericRecord>())) {
      return reader.getSchema();
    }
  }
532942
public static String getMD5Checksum(String str) throws IOException {

		InputStream is = new ByteArrayInputStream(str.getBytes());
		return getMD5Checksum(is);
	}
592231
def get_md5sum(src_file):
    """"""
    with open(src_file, 'rb') as src_data:
        src_content = src_data.read()
        return hashlib.md5(src_content).hexdigest()
1110119
function get_local_md5() {
        global $CFG;

    /// Check requisites are passed
        if (!$this->requisitesok) {
            return false;
        }

        $return_value = 'needtobeinstalled';   /// Fake value to force new installation

    /// Calculate source to read
       $source = $CFG->dataroot.'/'.$this->destpath.'/'.$this->componentname.'/'.$this->componentname.'.md5';
    /// Read md5 value stored (if exists)
       if (file_exists($source)) {
           if ($temp = file_get_contents($source)) {
               $return_value = $temp;
           }
        }
        return $return_value;
    }
1263911
def get_md5_for_file(file):
    
    md5 = hashlib.md5()

    while True:
        data = file.read(md5.block_size)

        if not data:
            break

        md5.update(data)

    return md5.hexdigest()
792374
public static byte[] md5(InputStream in) throws IOException {
		MD5InputStream md5in=new MD5InputStream(in);
		byte[] trashBuffer = BufferManager.getBytes();
		try {
			while(md5in.read(trashBuffer, 0, BufferManager.BUFFER_SIZE) != -1) {
				// Intentional empty block
			}
		} finally {
			BufferManager.release(trashBuffer, false);
		}
		return md5in.hash();
	}
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()
244382
def get_checksum(file):
    
    with open(file, 'rb') as FH:
        contents = FH.read()
    return hashlib.sha256(contents).hexdigest()