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 
   */ 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
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() 
	 */ 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
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 
   */ 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
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;
    } 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getMessageDigest
    public void close() throws IOException {
        super.close(); 
 
        closed = true;
        if ( byteOffset > 0 ) {
            checksums.add(digestInputStream.getMessageDigest().digest());
        } 
    } 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
   * @param messageDigest of type MessageDigest 
   * @param digestHex     of type String 
   */ 
  public FSDigestInputStream( InputStream inputStream, MessageDigest messageDigest, String digestHex )
    { 
    this.inputStream = digestHex == null ? inputStream : new DigestInputStream( inputStream, messageDigest );
    this.digestHex = digestHex;
    } 
 
  /** 
   * Method getMD5Digest returns the MD5Digest of this FSDigestInputStream object. 
   * 
   * @return the MD5Digest (type MessageDigest) of this FSDigestInputStream object. 
   * @throws IOException when 
   */ 
  private static MessageDigest getMD5Digest() throws IOException
    { 
    try 
      { 
      return MessageDigest.getInstance( "MD5" );
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
      System.err.println("Writes data to HDFS path from stdin");
      System.exit(2);
    } 
 
    MessageDigest hasher = FsEntryUtils.getHashInstance("MD5");
    DigestInputStream hashedIn = new DigestInputStream(System.in, hasher);
 
    FileSystem fs = FileSystem.get(conf);
    Path path = new Path(otherArgs[0]);
    FSDataOutputStream outFile = fs.create(path, true);
 
    IOUtils.copyLarge(hashedIn, outFile, new byte[1024 * 1024]);
 
    System.out.println(new String(Hex.encodeHex(hasher.digest())));
  } 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
    } 
 
    public Checksum update( InputStream stream )
        throws IOExceptionDigestInputStream dig = new DigestInputStream( stream, md );
        IOUtils.copy( dig, new NullOutputStream() );
 
        return this;
    } 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
        assertReadsFailWithNullPointerException(new DataInputStream(null));
    } 
 
    public void testDigestInputStream() throws IOException, NoSuchAlgorithmException { 
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        assertReadsFailWithNullPointerException(new DigestInputStream(null, md5));
    } 
 
    public void testFilterInputStream() throws IOException { 
        assertReadsFailWithNullPointerException(new FilterInputStream(null) {});
    } 
 
    public void testInflaterInputStream() throws IOException { 
        try { 
            new InflaterInputStream(null);
            fail();
        } catch (NullPointerException expected) {
        } 
        try { 
            new InflaterInputStream(null, new Inflater());
5
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Java 8 DigestInputStream Questions & Answers:

See Code Examples for Java 8 DigestInputStream Methods: