wm: teppich

ref: 3a52861b2d4179e7546c73bed693da37b752293e
dir: /libc/adler32.c/

View raw version
long
adler32(char *data)
{
	const int prime = 65521;
	int i = 0;
	int a = 0, b = 1;
	while (i < strlen(data))
	{
		b += data[i];
		a += b;
		i++;
	}
	b = b % prime;
	a = a % prime;
	return(b << 16 | a);
}