Methods Summary |
---|
public long | getValue()Returns current checksum value.
return (long)value & 0xffffffff;
|
public void | reset()Reset Adler-32 checksum to initial value.
value = 1;
|
public void | update(int b)Update current Adler-32 checksum given the specified byte.
int s1 = value & 0xffff;
int s2 = (value >> 16) & 0xffff;
s1 += b & 0xff;
s2 += s1;
value = ((s2 % BASE) << 16) | (s1 % BASE);
|
public void | update(byte[] b, int off, int len)Update current Adler-32 checksum given the specified byte array.
int s1 = value & 0xffff;
int s2 = (value >> 16) & 0xffff;
while (len > 0) {
int k = len < NMAX ? len : NMAX;
len -= k;
while (k-- > 0) {
s1 += b[off++] & 0xff;
s2 += s1;
}
s1 %= BASE;
s2 %= BASE;
}
value = (s2 << 16) | s1;
|