1 2 29 34 35 package com.jcraft.jzlib; 36 37 final class Adler32{ 38 39 static final private int BASE=65521; 41 static final private int NMAX=5552; 43 44 long adler32(long adler, byte[] buf, int index, int len){ 45 if(buf == null){ return 1L; } 46 47 long s1=adler&0xffff; 48 long s2=(adler>>16)&0xffff; 49 int k; 50 51 while(len > 0) { 52 k=len<NMAX?len:NMAX; 53 len-=k; 54 while(k>=16){ 55 s1+=buf[index++]&0xff; s2+=s1; 56 s1+=buf[index++]&0xff; s2+=s1; 57 s1+=buf[index++]&0xff; s2+=s1; 58 s1+=buf[index++]&0xff; s2+=s1; 59 s1+=buf[index++]&0xff; s2+=s1; 60 s1+=buf[index++]&0xff; s2+=s1; 61 s1+=buf[index++]&0xff; s2+=s1; 62 s1+=buf[index++]&0xff; s2+=s1; 63 s1+=buf[index++]&0xff; s2+=s1; 64 s1+=buf[index++]&0xff; s2+=s1; 65 s1+=buf[index++]&0xff; s2+=s1; 66 s1+=buf[index++]&0xff; s2+=s1; 67 s1+=buf[index++]&0xff; s2+=s1; 68 s1+=buf[index++]&0xff; s2+=s1; 69 s1+=buf[index++]&0xff; s2+=s1; 70 s1+=buf[index++]&0xff; s2+=s1; 71 k-=16; 72 } 73 if(k!=0){ 74 do{ 75 s1+=buf[index++]&0xff; s2+=s1; 76 } 77 while(--k!=0); 78 } 79 s1%=BASE; 80 s2%=BASE; 81 } 82 return (s2<<16)|s1; 83 } 84 85 94 } 95 | Popular Tags |