Code example for Adler32

Methods: getValue, update

0
    protected void setChecksum(long value) {
        setLong(0, value);
    } 
 
    protected long calculateChecksum() { 
        Checksum checksum = new Adler32();
        checksum.update(contents, POST_CHECKSUM_START, contents.length - POST_CHECKSUM_START);
        return checksum.getValue();
    } 
 
    /** 
     * @return true if the packet is of a valid length and the checksum is valid 
     */ 
    public boolean isGood() { 
        if (contents.length < HEADER_LENGTH) {
            return false; 
        } 
 
        long calcd = calculateChecksum();
        long curr = getChecksum();
        // log.info("Calculated: " + calcd + "; Checksum: " + curr);