Talk:Adler-32

From Wikipedia, the free encyclopedia

Contents

[edit] Adler-16

Adler-16 - does it exist? does anyone use it? User:Ojw

It's not hard to derive from the specification (you need another "base" of course, I'd suggest base 25110) but remember that the fewer bits you use the more "non-unique" and ambiguous the checksum becomes. Use in conjunction with another hash-algorithm Zero2ninE 19:20, 9 September 2007 (UTC)

[edit] Merge with Fletcher's checksum?

Maybe this should be merged with Fletcher's checksum? All that differs is one operation; the demonstration and discussion about performance is relevant for both. Duplicating the information would be unnecessary. Fredrik | talk 20:18, 26 Feb 2005 (UTC)

There's a larger difference in that Fletcher-32 accumulates 16 bits at a time, while Adler-32 accumulates 8 bits at a time. They are still very similar, though. User:68.205.112.194
Aren't you confusing it with Adler-16? Fredrik | talk 15:38, 27 Feb 2005 (UTC)

[edit] Example code license

Perhaps this is adequately covered elsewhere in the 'pedia, but this is the page that inspires the question for me. What's the license on the example code? I'm not entirely clear how the GFDL applies to code contained within. Is it similar to the GPL? -- Ventura 16:55, 2005 May 12 (UTC)

Wikipedia says: "When an author contributes original material to the project, the copyright over it is retained with them, but they agree to make the work available under the GFDL... all text is available under the GFDL"
Information about the license is available at its own page, or at GNU.org Ojw 17:07, 15 May 2005 (UTC)
Yes, it would be most convenient for me if the [| original author] would specifically say "this implementation public domain".
I'm going to ask at Wikipedia talk:Copyright FAQ. —The preceding unsigned comment was added by 68.0.120.35 (talk) 18:19, 27 January 2007 (UTC).

[edit] Optimized implementation as example?

The implementation in the RFC is much easier to read. Is there a reason to have a sample implementation here that is optimized for speed rather than clarity? 194.17.253.85 13:23, 11 April 2007 (UTC)

[edit] Error in maximum computation of b

The maximum value of b after the loop is actually 0xfff87 try the following program:

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<inttypes.h>
#define MOD_ADLER 65521
uint32_t
adler(uint8_t *data, size_t len) /* data: Pointer to the data to be summed; len is in bytes */
{
 
    uint32_t a = 1, b = 0;
 
    while (len)
    {
        size_t tlen = len > 5550 ? 5550 : len;
        len -= tlen;
        do
        {
            a += *data++;
            b += a;
        } while (--tlen);
 
        a = (a & 0xffff) + (a >> 16) * (65536-MOD_ADLER);
        b = (b & 0xffff) + (b >> 16) * (65536-MOD_ADLER);
 
    }
 
    /* It can be shown that a <= 0x1013a here, so a single subtract will do. */
    if (a >= MOD_ADLER)
            a -= MOD_ADLER;
 
printf("%x\n", b);
    /* It can be shown that b can reach 0xffef1 here. */
    b = (b & 0xffff) + (b >> 16) * (65536-MOD_ADLER);
 
    if (b >= MOD_ADLER)
            b -= MOD_ADLER;
 
    return (b << 16) | a;
 
}
 
int main(int argc, char **argv) {
  size_t num = 5550* 3;
  uint8_t *data = malloc(num);
  memset(data, -1, 256);
  memset(data + 256, 0, 5294);
  memset(data + 5550, -1, 5398);
  memset(data + 5550 + 5398, 20, 1);
  memset(data + 5550 + 5398 + 1, 0, 151);
 
  memset(data + 5550 * 2, -1, 5538);
  memset(data + 5550 * 2 + 5538, 220, 1);
  memset(data + 5550 * 2 + 5539, 0, 10);
  memset(data + 5550 * 2 + 5549, 5, 1);
  printf("%x\n", adler(data, num));
  return 0;
}

--70.48.50.99 (talk) 06:09, 20 November 2007 (UTC)

[edit] Optimized C code is subpar for current popular CPUs

Preliminary tests showed that simpler code that just use % MOD_ADLER is more than 3x faster on intel core 2 duo (tested on a macbook pro).

 data length: 407076728 (388.219MB)
 adler32: 0x35863d88 (1.219478s 318.348MB/s) adler32 (incremental): 0x35863d88
 adler32_mod: 0x35863d88 (0.365084s 1063.367MB/s)
 adler32_lzo: 0x35863d88 (1.520710s 255.288MB/s)
 fletcher32: 0x2f086256 (0.531902s 729.869MB/s)
 fletcher32a: 0x2f086256 (0.278072s 1396.109MB/s)

Note, the adler32 from lzo library (noted for its speed) uses manual loop unrolling and is the slowest.

This is an example of premature optimization. —Preceding unsigned comment added by Vicaya (talk • contribs) 00:56, 3 January 2008 (UTC)

I'm OK with having the simpler code example in the article, but please be careful with original research in the future. -- intgr [talk] 01:18, 3 January 2008 (UTC)

[edit] Articles comment about 5550 is superfluous

I don't believe the comment about 5550 on the article page itself is of any use, the current simple code which does a full reduction is indeed safe at the RFC listed value of 5552 (and should be changed to use this value). MaZe Pallas (talk) 11:23, 24 February 2008 (UTC)