com.partnersoft.io.net
Class RsyncLib

java.lang.Object
  extended by com.partnersoft.io.net.RsyncLib

public class RsyncLib
extends java.lang.Object

Implementations of methods needed to implement the rsync algorithm. Not intended to replace rsync or be compatible with it, so watch out. There is at least one project (jarsync) intended to be compatible so go there if you want it. Rsync info is at http://rsync.samba.org.

Author:
Paul Reavis Copyright 2004 Partner Software, Inc.

Constructor Summary
RsyncLib()
           
 
Method Summary
static java.security.MessageDigest createDigest()
          Get an MD5 MessageDigest object.
static boolean digestsMatch(byte[] digest1, byte[] digest2)
           
static short hash(int weakChecksum)
          Generates a 16-bit hash for the given 32-bit weak checksum.
static java.util.ArrayList listFiles(java.io.File rootDir)
          Generate a list of file paths beneath a root dir.
static int rollWeakChecksum(int checksum, int oldByte, int newByte, int blocksize)
          Update the given checksum in a rolling fashion.
static byte[] strongChecksum(byte[] bytes, int start, int length)
          Generate a 128-bit strong checksum on the given bytes.
static int weakChecksum(byte[] bytes, int start, int length)
          Generate a 32-bit weak checksum on the given bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RsyncLib

public RsyncLib()
Method Detail

hash

public static short hash(int weakChecksum)
Generates a 16-bit hash for the given 32-bit weak checksum.


weakChecksum

public static int weakChecksum(byte[] bytes,
                               int start,
                               int length)
Generate a 32-bit weak checksum on the given bytes. Uses the published rsync rolling weak checksum (http://rsync.samba.org/tech_report/node3.html).


rollWeakChecksum

public static int rollWeakChecksum(int checksum,
                                   int oldByte,
                                   int newByte,
                                   int blocksize)
Update the given checksum in a rolling fashion.


strongChecksum

public static byte[] strongChecksum(byte[] bytes,
                                    int start,
                                    int length)
Generate a 128-bit strong checksum on the given bytes. Uses MD5 digest.


createDigest

public static java.security.MessageDigest createDigest()
Get an MD5 MessageDigest object.


digestsMatch

public static boolean digestsMatch(byte[] digest1,
                                   byte[] digest2)

listFiles

public static java.util.ArrayList listFiles(java.io.File rootDir)
                                     throws java.io.IOException
Generate a list of file paths beneath a root dir.

Throws:
java.io.IOException