Examples of DigestInputStream


Examples of java.security.DigestInputStream

    public static String getDigestOf(InputStream source) throws IOException {
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");

            byte[] buffer = new byte[1024];
            DigestInputStream in =new DigestInputStream(source,md5);
            try {
                while(in.read(buffer)>0)
                    ; // simply discard the input
            } finally {
                in.close();
            }
            return toHexString(md5.digest());
        } catch (NoSuchAlgorithmException e) {
            throw new IOException2("MD5 not installed",e);    // impossible
        }
View Full Code Here

Examples of java.security.DigestInputStream

      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);
View Full Code Here

Examples of java.security.DigestInputStream

                File src = (File) e.nextElement();
                if (!isCondition) {
                    log("Calculating " + algorithm + " checksum for " + src);
                }
                fis = new FileInputStream(src);
                DigestInputStream dis = new DigestInputStream(fis,
                                                              messageDigest);
                while (dis.read(buf, 0, readBufferSize) != -1) {
                    ;
                }
                dis.close();
                fis.close();
                fis = null;
                byte[] fileDigest = messageDigest.digest ();
                StringBuffer checksumSb = new StringBuffer();
                for (int i = 0; i < fileDigest.length; i++) {
View Full Code Here

Examples of java.security.DigestInputStream

      MessageDigest digester = null;
     
      if (in == null) {
        FileInputStream fis = new FileInputStream(curFile);
        digester = MD5Hash.getDigester();
        DigestInputStream fin = new DigestInputStream(
           fis, digester);
        in = new DataInputStream(fin);
      }    
      try {
        /*
 
View Full Code Here

Examples of java.security.DigestInputStream

    long received = 0;
    InputStream stream = connection.getInputStream();
    MessageDigest digester = null;
    if (getChecksum) {
      digester = MD5Hash.getDigester();
      stream = new DigestInputStream(stream, digester);
    }
    FileOutputStream[] output = null;
   
    try {
      if (localPath != null) {
View Full Code Here

Examples of java.security.DigestInputStream

      {
         byte[] buffer = new byte[1 << 4];
         MessageDigest md = MessageDigest.getInstance("MD5");

         FileInputStream is = new FileInputStream(file);
         DigestInputStream is2 = new DigestInputStream(is, md);
         while (is2.read(buffer) > 0)
         {
            continue;
         }
         byte[] digest = md.digest();
         is.close();
         is2.close();
         return Base64.encodeBytes(digest);
      }
      catch (Exception e)
      {
         throw new RuntimeException(e);
View Full Code Here

Examples of java.security.DigestInputStream

                log.error(msg);
                throw new DataStoreException(msg);
            }
            temporaryInUse.add(tempId);
            MessageDigest digest = getDigest();
            DigestInputStream dIn = new DigestInputStream(stream, digest);
            TrackingInputStream in = new TrackingInputStream(dIn);
            StreamWrapper wrapper;
            if (STORE_SIZE_MINUS_ONE.equals(storeStream)) {
                wrapper = new StreamWrapper(in, -1);
            } else if (STORE_SIZE_MAX.equals(storeStream)) {
View Full Code Here

Examples of java.security.DigestInputStream

            FileOutputStream fos = null;
            byte[] buf = new byte[readBufferSize];
            try {
                messageDigest.reset();
                fis = new FileInputStream(file);
                DigestInputStream dis = new DigestInputStream(fis,
                                                              messageDigest);
                while (dis.read(buf, 0, readBufferSize) != -1) {
                    // do nothing
                }
                dis.close();
                fis.close();
                fis = null;
                byte[] fileDigest = messageDigest.digest();
                StringBuffer checksumSb = new StringBuffer();
                for (int i = 0; i < fileDigest.length; i++) {
View Full Code Here

Examples of java.security.DigestInputStream

                File src = (File) e.nextElement();
                if (!isCondition) {
                    log("Calculating " + algorithm + " checksum for " + src, Project.MSG_VERBOSE);
                }
                fis = new FileInputStream(src);
                DigestInputStream dis = new DigestInputStream(fis,
                                                              messageDigest);
                while (dis.read(buf, 0, readBufferSize) != -1) {
                    ;
                }
                dis.close();
                fis.close();
                fis = null;
                byte[] fileDigest = messageDigest.digest ();
                if (totalproperty != null) {
                    allDigests.put(src, fileDigest);
View Full Code Here

Examples of java.security.DigestInputStream

        try {
            messageDigest = MessageDigest.getInstance(HASH_ALGORITHM);
        } catch (NoSuchAlgorithmException e) {
            throw new IOException(e);
        }
        DigestInputStream din = new DigestInputStream(in, messageDigest);
        long length = file.length();
        try {
            while (true) {
                int len = din.read(buffer, 0, buffer.length);
                if (len < 0) {
                    break;
                }
            }
        } finally {
            din.close();
        }
        ByteArrayOutputStream idStream = new ByteArrayOutputStream();
        idStream.write(TYPE_HASH);
        IOUtils.writeVarInt(idStream, 0);
        IOUtils.writeVarLong(idStream, length);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.