FileDocCategorySizeDatePackage
ParityChecksum.javaAPI DocExample600Sun Mar 28 19:07:26 BST 1999None

ParityChecksum

public class ParityChecksum extends Object implements Checksum

Fields Summary
private long
checksum
Constructors Summary
Methods Summary
public longgetValue()

    return checksum;
  
public voidreset()

    checksum = 0;
  
public voidupdate(int b)


      
  
    int numOneBits = 0;
    for (int i = 1; i < 256; i *= 2) {
      if ((b & i) != 0) numOneBits++;
    } 
    checksum = (checksum + numOneBits) % 2;
    
  
public voidupdate(byte[] data, int offset, int length)

  
    for (int i = offset; i < offset+length; i++) {
      this.update(data[i]);
    }