Package org.jmule.core.utils

Examples of org.jmule.core.utils.MD4


           
            int c;
           
            ByteBuffer hashset;
           
            MD4 msgDigest = new MD4();
           
            ByteBuffer bb = ByteBuffer.allocateDirect(8192).order(ByteOrder.LITTLE_ENDIAN);
           
            ByteBuffer di = ByteBuffer.allocate(16).order(ByteOrder.LITTLE_ENDIAN);
           
            c = (int) ((fileChannel.size() + PARTSIZE - 1) / PARTSIZE);
           
            // we will need space for c Parts
            hashset = ByteBuffer.allocate(16 * (c>0?c:1)).order(ByteOrder.LITTLE_ENDIAN);
           
            for (i = 1; i < c; i++) {
             
                while (position <= (i * PARTSIZE - bb.capacity())) {
                 
                  if( stop ) return;
                 
                    position+=fileChannel.read(bb, position);
                   
                    bb.flip();
                   
                    msgDigest.update(bb);
                   
                    bb.rewind();
                   
                }
           
                if (position < (i * PARTSIZE)) {
                 
                    bb.limit((int) ((i * PARTSIZE) - position));
                   
                    position+=fileChannel.read(bb, position);
                   
                    bb.flip();
                   
                    msgDigest.update(bb);
                   
                    bb.rewind();
                   
                }
               
                 hashset.limit(16 * i);
                
                 //update hashset - add a hash
                 msgDigest.finalDigest(hashset);
                
            }
           
            if (c > 0) {
             
                while (position < (fileChannel.size())) {
                 
                  if(stop) return;
                 
                    position+=fileChannel.read(bb, position);
                   
                    bb.flip();
                   
                    msgDigest.update(bb);
                   
                    bb.rewind();
                   
                }
               
                hashset.limit(16 * i);
               
            }
           
            msgDigest.finalDigest(hashset);
          
            hashset.flip();
           
            if (c > 1) {
             
                msgDigest.update(hashset);
               
                msgDigest.finalDigest(di);
               
            } else {
             
                di.put(hashset);
               
View Full Code Here


 
  private boolean checkPartIntegrity(int partID) {
   
    long start = PARTSIZE*partID;
   
    MD4 msgDigest = new MD4();
   
    ByteBuffer partData = Misc.getByteBuffer(PARTSIZE);
    msgDigest.reset();
    try {
     
      readChannel.position(start);
     
      int count = readChannel.read(partData);
      partData.limit(count);
      msgDigest.update(partData);
     
      ByteBuffer hashset = Misc.getByteBuffer(16);
     
      msgDigest.finalDigest(hashset);
     
      if (!Arrays.equals(hashSet.get(partID),hashset.array())) {
        return false;
      }
      return true;
View Full Code Here

TOP

Related Classes of org.jmule.core.utils.MD4

Copyright © 2018 www.massapicom. 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.