Examples of DigestOutputStream


Examples of java.security.DigestOutputStream

         try
         {
            long hash = 0;
            ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(512);
            MessageDigest messagedigest = MessageDigest.getInstance("SHA");
            DataOutputStream dataoutputstream = new DataOutputStream(new DigestOutputStream(bytearrayoutputstream, messagedigest));
            dataoutputstream.writeUTF(methodDesc);
            dataoutputstream.flush();
            byte abyte0[] = messagedigest.digest();
            for(int j = 0; j < Math.min(8, abyte0.length); j++)
               hash += (long)(abyte0[j] & 0xff) << j * 8;
 
View Full Code Here

Examples of java.security.DigestOutputStream

   
    FileOutputStream fos = new FileOutputStream(target);
    BufferedOutputStream bos = new BufferedOutputStream(fos);
    if(digest) {
      digester = MessageDigest.getInstance("MD5");
      os = new DigestOutputStream(bos,digester);
    } else {
      os = bos;
    }
    int BUF_SIZE = 4096;
    byte[] buffer = new byte[BUF_SIZE];
View Full Code Here

Examples of java.security.DigestOutputStream

         try
         {
            long hash = 0;
            ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(512);
            MessageDigest messagedigest = MessageDigest.getInstance("SHA");
            DataOutputStream dataoutputstream = new DataOutputStream(new DigestOutputStream(bytearrayoutputstream, messagedigest));
            dataoutputstream.writeUTF(methodDesc);
            dataoutputstream.flush();
            byte abyte0[] = messagedigest.digest();
            for(int j = 0; j < Math.min(8, abyte0.length); j++)
               hash += (long)(abyte0[j] & 0xff) << j * 8;
 
View Full Code Here

Examples of java.security.DigestOutputStream

      this.conf = conf;
      this.key = key;
      this.backupFile = newBackupFile();
      try {
        this.digest = MessageDigest.getInstance("MD5");
        this.backupStream = new BufferedOutputStream(new DigestOutputStream(
            new FileOutputStream(backupFile), this.digest));
      } catch (NoSuchAlgorithmException e) {
        LOG.warn("Cannot load MD5 digest algorithm," +
            "skipping message integrity check.", e);
        this.backupStream = new BufferedOutputStream(
View Full Code Here

Examples of java.security.DigestOutputStream

    private void saveInternal(FileOutputStream fout,
        FSImageCompression compression, String filePath) throws IOException {
      StartupProgress prog = NameNode.getStartupProgress();
      MessageDigest digester = MD5Hash.getDigester();

      underlyingOutputStream = new DigestOutputStream(new BufferedOutputStream(
          fout), digester);
      underlyingOutputStream.write(FSImageUtil.MAGIC_HEADER);

      fileChannel = fout.getChannel();
View Full Code Here

Examples of java.security.DigestOutputStream

      //
      // Write out data
      //
      MessageDigest digester = MD5Hash.getDigester();
      FileOutputStream fout = new FileOutputStream(newFile);
      DigestOutputStream fos = new DigestOutputStream(fout, digester);
      DataOutputStream out = new DataOutputStream(fos);
      try {
        out.writeInt(LAYOUT_VERSION);
        LayoutFlags.write(out);
        // We use the non-locked version of getNamespaceInfo here since
View Full Code Here

Examples of java.security.DigestOutputStream

      this.key = key;
      this.backupFile = newBackupFile();
      LOG.info("OutputStream for key '" + key + "' writing to tempfile '" + this.backupFile + "'");
      try {
        this.digest = MessageDigest.getInstance("MD5");
        this.backupStream = new BufferedOutputStream(new DigestOutputStream(
            new FileOutputStream(backupFile), this.digest));
      } catch (NoSuchAlgorithmException e) {
        LOG.warn("Cannot load MD5 digest algorithm," +
            "skipping message integrity check.", e);
        this.backupStream = new BufferedOutputStream(
View Full Code Here

Examples of java.security.DigestOutputStream

   * @param dst
   *            the stream this instance outputs to. If not already buffered
   *            it will be automatically wrapped in a buffered stream.
   */
  protected PackIndexWriter(final OutputStream dst) {
    out = new DigestOutputStream(dst instanceof BufferedOutputStream ? dst
        : new SafeBufferedOutputStream(dst),
        Constants.newMessageDigest());
    tmp = new byte[4 + Constants.OBJECT_ID_LENGTH];
  }
View Full Code Here

Examples of java.security.DigestOutputStream

    }
  }

  void writeTo(final OutputStream os) throws IOException {
    final MessageDigest foot = Constants.newMessageDigest();
    final DigestOutputStream dos = new DigestOutputStream(os, foot);

    boolean extended = false;
    for (int i = 0; i < entryCnt; i++)
      extended |= sortedEntries[i].isExtended();

    // Write the header.
    //
    final byte[] tmp = new byte[128];
    System.arraycopy(SIG_DIRC, 0, tmp, 0, SIG_DIRC.length);
    NB.encodeInt32(tmp, 4, extended ? 3 : 2);
    NB.encodeInt32(tmp, 8, entryCnt);
    dos.write(tmp, 0, 12);

    // Write the individual file entries.
    //
    if (snapshot == null) {
      // Write a new index, as no entries require smudging.
      //
      for (int i = 0; i < entryCnt; i++)
        sortedEntries[i].write(dos);
    } else {
      final int smudge_s = (int) (snapshot.lastModified() / 1000);
      final int smudge_ns = ((int) (snapshot.lastModified() % 1000)) * 1000000;
      for (int i = 0; i < entryCnt; i++) {
        final DirCacheEntry e = sortedEntries[i];
        if (e.mightBeRacilyClean(smudge_s, smudge_ns))
          e.smudgeRacilyClean();
        e.write(dos);
      }
    }

    if (tree != null) {
      final TemporaryBuffer bb = new TemporaryBuffer.LocalFile();
      tree.write(tmp, bb);
      bb.close();

      NB.encodeInt32(tmp, 0, EXT_TREE);
      NB.encodeInt32(tmp, 4, (int) bb.length());
      dos.write(tmp, 0, 8);
      bb.writeTo(dos, null);
    }

    os.write(foot.digest());
    os.close();
View Full Code Here

Examples of java.security.DigestOutputStream

           throws Exception
   {
      long hash = 0;
      ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(512);
      MessageDigest messagedigest = MessageDigest.getInstance("SHA");
      DataOutputStream dataoutputstream = new DataOutputStream(new DigestOutputStream(bytearrayoutputstream, messagedigest));
      dataoutputstream.writeUTF(methodDesc);
      dataoutputstream.flush();
      byte abyte0[] = messagedigest.digest();
      for (int j = 0; j < Math.min(8, abyte0.length); j++)
         hash += (long) (abyte0[j] & 0xff) << j * 8;
 
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.