Adler-32 is a fast checksum algorithm used in zlib to verify the results of decompression. It is composed of two sums modulo 65521. Start with s1 = 1 and s2 = 0, then for each byte x, s1 = s1 + x, s2 = s2 + s1. The two sums are combined into a 32-bit value with s1 in the low 16 bits and s2 in the high 16 bits.
Questions tagged [adler32]
39 questions
1
vote
2 answers
Crypto++ convert Adler32 digest (byte array) to uint32_t
I have the following problem: I'm trying to calculate the adler32 checksum of a data block using Crypto++, but I get the wrong checksum after converting the byte[4] array output to a uint32_t.
This function with crc32 works just…

Fabian
- 152
- 2
- 14
1
vote
2 answers
python3 and numba, wrong calculation of adler32 checksum
I have written the same algorithm in 3 flavours:
plain Python
Python optimized with Numba
Micropython optimized with Viper
I am sure about the correctness of the routine in plain Python and Micropython: the checksum on some megabytes of random…

Massimo
- 3,171
- 3
- 28
- 41
1
vote
1 answer
Non-cryptographic hash functions that are homomorphic with respect to concatenation
Adler32 and CRC have the property that f(a || b) can be computed inexpensively from f(a), f(b), and len(b). Are there any other common non-cryptographic hash functions with this property?
Context (to avoid XY problem) is that I am deduplicating…

Alex
- 43
- 5
1
vote
1 answer
Why does my Adler-32 Hash Function miss a zero every time?
I'm trying to code the Adler-32 Hash Function from scratch just to have some fun, I've gotten it completed except for the fact that every time I hash a string it's always missing the zero in the front. I've gone through the formula and Adler-32…

mCore-Tech
- 13
- 2
1
vote
0 answers
How to compute the Adler32 in zlib
Regarding the checksum, adler32, used in zlib.
From rfc 1950:
ADLER32: This contains a checksum value of the uncompressed data (excluding any dictionary data) computed according to Adler-32 algorithm.
Here is a png (zlib in IDAT).
blue = length, 4…

Dave P
- 145
- 8
1
vote
2 answers
A palette base PNG with IDAT that has BTYPE=00 for no compression, now with Adler32 code
I am working on some code that builds simple palette based PNG files without libpng. The output file, at this stage only has IHDR, PLTE, IDAT(x3) and IEND chunks. The only thing which is possibly a bit different in that the pixel index values in…

SkyPirate
- 35
- 6
1
vote
1 answer
When is it appropriate to use a simple modulus as a hashing function?
I need to create a 16 bit hash from a 32 bit number, and I'm trying to determine if a simple modulus 2^16 is appropriate.
The hash will be used in a 2^16 entry hash table for fast lookup of the 32 bit number.
My understanding is that if the data…

Clayton Gulick
- 9,755
- 2
- 36
- 26
0
votes
5 answers
Algorithm for message code validation
If you read this thread before - forget everything I wrote, I must have been drunk when I wrote it. I'm starting over:
I'm currently working on a project where we will be using some sort of algorithm for validating user input. There are three…

Björn
- 29,019
- 9
- 65
- 81
0
votes
0 answers
Why is ```(n+1)(BASE-1)``` added when calculating the NMAX of Adler-32?
zlib/adler32.c
code is:
#define BASE 65521U /* largest prime smaller than 65536 */
#define NMAX 5552
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
but I think it should be calculated like this:
255n(n+1)/2 + n <…

minchai
- 13
- 3
0
votes
3 answers
How to calculate Adler32 checksum for zip in Bash?
I need get checksum Adler32 and store to variable in bash.
It will be used in automatic script and it will be useful if no additional app/liberty will used which user need to install.
Is it possible to use common / basic command Bash command to get…

errorfree
- 103
- 1
- 1
- 8
0
votes
1 answer
Compressed AS2 Body
I am struggling with decompression of a Zlib compressed Mime body of AS2 request coming from BizTalk Server.
The thing is:
The HTTP Body I receive looks as expected. I can read the ASCII encoded Mime Header:
"Content-type: application/pkcs7-mime;…

Trombone
- 1
- 1
0
votes
1 answer
Adler32 generated checksum doesnt match the .txt files checksum
im tasked with written two java programs. One program creates a file called 'userinput.txt', then writes everything the user inputs into the file. Once done a new file is created called 'Checksum.txt' and this file will write down the checksum for…

Huseyin Yesiler
- 85
- 1
- 2
- 11
0
votes
1 answer
Can a stream contain some fix huffman compressed block and some dynamic huffman compressed blocks
Is it possible to compress a stream with some blocks compressed with static Huffman encoding, and some blocks compressed with dynamic Huffman encoding? If yes, is it decompressible ?

raj_gt1
- 4,653
- 2
- 20
- 28
0
votes
1 answer
Deflate data decompression zlib
I'm working with zlib and have some problem with decompression. I try to decompress packets that come to "inflate" function but "inflate" returns me -3. Combination of 00 00 00 ff ff tell me that data is compressed by deflate algorithm. So i try to…

rooltex
- 134
- 3
- 18
0
votes
1 answer
Adler-32 checksum generating - why bit and shift right operator are used
I've found method which implements Adler32 algorithm in C# and I would like to use it, but I do not understand part of the code:
Can someone explain me:
1) why bit operators are used when sum1, and sum2 are initialized
2) why sum2 is shifted…

Jacob
- 345
- 1
- 8
- 17