Java 8 DigestInputStream - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 DigestInputStream class.

This code example shows how to use the following methods:
   */ 
  public static MD5Hash computeMd5ForFile(File dataFile) throws IOException {
    InputStream in = new FileInputStream(dataFile);
    try { 
      MessageDigest digester = MD5Hash.getDigester();
      DigestInputStream dis = new DigestInputStream(in, digester);
      IOUtils.copyBytes(dis, new IOUtils.NullOutputStream(), 128*1024);
       
      return new MD5Hash(digester.digest());
    } finally { 
      IOUtils.closeStream(in);
    } 
  } 
 
  /** 
   * Save the ".md5" file that lists the md5sum of another file. 
   * @param dataFile the original file whose md5 was computed 
   * @param digest the computed digest 
   * @throws IOException 
   */ 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: on, read
        // changed 
        assertTrue("MessageDigest changed even though processing was off",
                MessageDigest.isEqual(noChangeDigest.digest(), originalDigest
                        .digest()));
        MessageDigest changeDigest = (MessageDigest) (digest.clone());
        dis = new DigestInputStream(inStream, digest);
 
        // turn on processing 
        dis.on(true);
        c = dis.read();
        assertEquals('h', c);
 
        // make sure the digest has changed 
        assertTrue("MessageDigest did not change with processing on",
                !MessageDigest.isEqual(digest.digest(), changeDigest.digest()));
    } 
 
	/** 
	 * @tests java.security.DigestInputStream#read() 
	 */ 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
   */ 
  public static MD5Hash computeMd5ForFile(File dataFile) throws IOException {
    InputStream in = new FileInputStream(dataFile);
    try { 
      MessageDigest digester = MD5Hash.getDigester();
      DigestInputStream dis = new DigestInputStream(in, digester);
      IOUtils.copyBytes(dis, new IOUtils.NullOutputStream(), 128*1024);
       
      return new MD5Hash(digester.digest());
    } finally { 
      IOUtils.closeStream(in);
    } 
  } 
 
  /** 
   * Save the ".md5" file that lists the md5sum of another file. 
   * @param dataFile the original file whose md5 was computed 
   * @param digest the computed digest 
   * @throws IOException 
   */ 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
This code example shows how to use the following methods:
            result = getComputedDigest();
        } else if (isAvailable()) { 
            try { 
                java.security.MessageDigest md = java.security.MessageDigest
                        .getInstance(algorithm);
                java.security.DigestInputStream dis = new java.security.DigestInputStream(
                        getStream(), md);
                org.restlet.engine.io.IoUtils.exhaust(dis);
                result = new org.restlet.data.Digest(algorithm, md.digest());
            } catch (java.security.NoSuchAlgorithmException e) {
                Context.getCurrentLogger().log(Level.WARNING,
                        "Unable to check the digest of the representation.", e);
            } catch (IOException e) {
                Context.getCurrentLogger().log(Level.WARNING,
                        "Unable to check the digest of the representation.", e);
            } 
        } 
 
        return result;
    } 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Java 8 DigestInputStream Questions & Answers:

See Code Examples for Java 8 DigestInputStream Methods: