<s>
Adler-32	B-Algorithm
is	O
a	O
checksum	B-Algorithm
algorithm	O
written	O
by	O
Mark	O
Adler	O
in	O
1995	O
,	O
modifying	O
Fletcher	B-Algorithm
's	I-Algorithm
checksum	I-Algorithm
.	O
</s>
<s>
Adler-32	B-Algorithm
is	O
more	O
reliable	O
than	O
Fletcher-16	O
,	O
and	O
slightly	O
less	O
reliable	O
than	O
Fletcher-32	O
.	O
</s>
<s>
The	O
Adler-32	B-Algorithm
checksum	B-Algorithm
is	O
part	O
of	O
the	O
widely	O
used	O
zlib	B-Language
compression	O
library	O
,	O
as	O
both	O
were	O
developed	O
by	O
Mark	O
Adler	O
.	O
</s>
<s>
A	O
"	O
rolling	B-Error_Name
checksum	I-Error_Name
"	O
version	O
of	O
Adler-32	B-Algorithm
is	O
used	O
in	O
the	O
rsync	B-Application
utility	O
.	O
</s>
<s>
An	O
Adler-32	B-Algorithm
checksum	B-Algorithm
is	O
obtained	O
by	O
calculating	O
two	O
16-bit	B-Device
checksums	B-Algorithm
A	O
and	O
B	O
and	O
concatenating	O
their	O
bits	O
into	O
a	O
32-bit	O
integer	O
.	O
</s>
<s>
A	O
is	O
the	O
sum	O
of	O
all	O
bytes	B-Application
in	O
the	O
stream	O
plus	O
one	O
,	O
and	O
B	O
is	O
the	O
sum	O
of	O
the	O
individual	O
values	O
of	O
A	O
from	O
each	O
step	O
.	O
</s>
<s>
At	O
the	O
beginning	O
of	O
an	O
Adler-32	B-Algorithm
run	O
,	O
A	O
is	O
initialized	O
to	O
1	O
,	O
B	O
to	O
0	O
.	O
</s>
<s>
The	O
bytes	B-Application
are	O
stored	O
in	O
network	O
order	O
(	O
big	O
endian	O
)	O
,	O
B	O
occupying	O
the	O
two	O
most	O
significant	O
bytes	B-Application
.	O
</s>
<s>
where	O
D	O
is	O
the	O
string	O
of	O
bytes	B-Application
for	O
which	O
the	O
checksum	B-Algorithm
is	O
to	O
be	O
calculated	O
,	O
and	O
n	O
is	O
the	O
length	O
of	O
D	O
.	O
</s>
<s>
The	O
Adler-32	B-Algorithm
sum	O
of	O
the	O
ASCII	B-Protocol
string	O
"	O
Wikipedia	O
"	O
would	O
be	O
calculated	O
as	O
follows	O
:	O
</s>
<s>
The	O
first	O
difference	O
between	O
the	O
two	O
algorithms	O
is	O
that	O
Adler-32	B-Algorithm
sums	O
are	O
calculated	O
modulo	O
a	O
prime	O
number	O
,	O
whereas	O
Fletcher	O
sums	O
are	O
calculated	O
modulo	O
24−1	O
,	O
28−1	O
,	O
or	O
216−1	O
(	O
depending	O
on	O
the	O
number	O
of	O
bits	O
used	O
)	O
,	O
which	O
are	O
all	O
composite	O
numbers	O
.	O
</s>
<s>
Using	O
a	O
prime	O
number	O
makes	O
it	O
possible	O
for	O
Adler-32	B-Algorithm
to	O
catch	O
differences	O
in	O
certain	O
combinations	O
of	O
bytes	B-Application
that	O
Fletcher	O
is	O
unable	O
to	O
detect	O
.	O
</s>
<s>
The	O
second	O
difference	O
,	O
which	O
has	O
the	O
largest	O
effect	O
on	O
the	O
speed	O
of	O
the	O
algorithm	O
,	O
is	O
that	O
the	O
Adler	O
sums	O
are	O
computed	O
over	O
8-bit	O
bytes	B-Application
rather	O
than	O
16-bit	B-Device
words	O
,	O
resulting	O
in	O
twice	O
the	O
number	O
of	O
loop	O
iterations	O
.	O
</s>
<s>
This	O
results	O
in	O
the	O
Adler-32	B-Algorithm
checksum	B-Algorithm
taking	O
between	O
one-and-a-half	O
to	O
two	O
times	O
as	O
long	O
as	O
Fletcher	B-Algorithm
's	I-Algorithm
checksum	I-Algorithm
for	O
16-bit	B-Device
word	O
aligned	O
data	O
.	O
</s>
<s>
For	O
byte-aligned	O
data	O
,	O
Adler-32	B-Algorithm
is	O
faster	O
than	O
a	O
properly	O
implemented	O
Fletcher	B-Algorithm
's	I-Algorithm
checksum	I-Algorithm
(	O
e.g.	O
,	O
one	O
found	O
in	O
the	O
Hierarchical	B-Application
Data	I-Application
Format	I-Application
)	O
.	O
</s>
<s>
In	O
C	B-Language
,	O
an	O
inefficient	O
but	O
straightforward	O
implementation	O
is	O
:	O
</s>
<s>
See	O
the	O
zlib	B-Language
source	O
code	O
for	O
a	O
more	O
efficient	O
implementation	O
that	O
requires	O
a	O
fetch	O
and	O
two	O
additions	O
per	O
byte	B-Application
,	O
with	O
the	O
modulo	O
operations	O
deferred	O
with	O
two	O
remainders	O
computed	O
every	O
several	O
thousand	O
bytes	B-Application
,	O
a	O
technique	O
first	O
discovered	O
for	O
Fletcher	B-Algorithm
checksums	I-Algorithm
in	O
1988	O
.	O
provides	O
a	O
similar	O
optimization	O
,	O
with	O
the	O
addition	O
of	O
a	O
trick	O
that	O
delays	O
computing	O
the	O
"	O
15	O
"	O
in	O
65536	O
-	O
65521	O
so	O
that	O
modulos	O
become	O
faster	O
:	O
it	O
can	O
be	O
shown	O
that	O
is	O
equivalent	O
to	O
the	O
naive	O
accumulation	O
.	O
</s>
<s>
Like	O
the	O
standard	O
CRC-32	O
,	O
the	O
Adler-32	B-Algorithm
checksum	B-Algorithm
can	O
be	O
forged	O
easily	O
and	O
is	O
therefore	O
unsafe	O
for	O
protecting	O
against	O
intentional	O
modification	O
.	O
</s>
<s>
Adler-32	B-Algorithm
has	O
a	O
weakness	O
for	O
short	O
messages	O
with	O
a	O
few	O
hundred	O
bytes	B-Application
,	O
because	O
the	O
checksums	B-Algorithm
for	O
these	O
messages	O
have	O
a	O
poor	O
coverage	O
of	O
the	O
32	O
available	O
bits	O
.	O
</s>
<s>
Adler-32	B-Algorithm
is	O
weak	O
for	O
short	O
messages	O
because	O
the	O
sum	O
A	O
does	O
not	O
wrap	O
.	O
</s>
<s>
The	O
maximum	O
sum	O
of	O
a	O
128-byte	O
message	O
is	O
32640	O
,	O
which	O
is	O
below	O
the	O
value	O
65521	O
used	O
by	O
the	O
modulo	O
operation	O
,	O
meaning	O
that	O
roughly	O
half	O
of	O
the	O
output	O
space	O
is	O
unused	O
,	O
and	O
the	O
distribution	O
within	O
the	O
used	O
part	O
is	O
nonuniform	O
.	O
</s>
<s>
CRC32C	O
instead	O
of	O
Adler-32	B-Algorithm
for	O
SCTP	B-Protocol
,	O
the	O
Stream	B-Protocol
Control	I-Protocol
Transmission	I-Protocol
Protocol	I-Protocol
.	O
</s>
<s>
Adler-32	B-Algorithm
has	O
also	O
been	O
shown	O
to	O
be	O
weak	O
for	O
small	O
incremental	O
changes	O
,	O
and	O
also	O
weak	O
for	O
strings	O
generated	O
from	O
a	O
common	O
prefix	O
and	O
consecutive	O
numbers	O
(	O
like	O
auto-generated	O
label	O
names	O
by	O
typical	O
code	O
generators	O
)	O
.	O
</s>
