Adler32C Class
Definition
Computes a 32-bit Adler-style checksum using the power-of-two modulus 65536 instead of the prime 65521. This class cannot be inherited.
public sealed class Adler32C : Adler32Base, IResumableHashAlgorithm
- Inheritance
-
Adler32C
- Implements
- Inherited Members
- Extension Methods
-
NonCryptographicHashAlgorithmExtensions.ComputeHash(NonCryptographicHashAlgorithm, byte[], int, int)NonCryptographicHashAlgorithmExtensions.TryVerifyHash(NonCryptographicHashAlgorithm, byte[], byte[])NonCryptographicHashAlgorithmExtensions.TryVerifyHash(NonCryptographicHashAlgorithm, byte[], string)NonCryptographicHashAlgorithmExtensions.TryVerifyHash(NonCryptographicHashAlgorithm, Stream, byte[])
Remarks
This variant maintains two running sums (A and B) and combines them as (B << 16) | A, but uses a
modulus of 65536 rather than the standard 65521. It runs the same scalar loop as Adler32, so the
power-of-two modulus brings no speed advantage here, and it detects fewer errors than the prime modulus. Outputs
differ from standard Adler32 and are not interchangeable.
Parameters at a glance.
- Output size: 32 bits (4 bytes).
- Modulus:
65536(power of two). - Compatibility: not interchangeable with Adler32 outputs.
When to choose Adler32C. Pick Adler32C only to match an existing system that computes Adler sums modulo 65536. For new internal checksums Adler32 costs the same and detects more errors, and for any boundary that interoperates with zlib, deflate, gzip, PNG, or other external systems use Adler32 - its output is the only one those systems will accept.
important
This algorithm is not cryptographically secure and should not be used for password hashing, digital signatures, or integrity validation in security-sensitive applications.
using Bodu.IO.Hashing.Checksums;
using Bodu.IO.Hashing.Extensions;
// Adler sum modulo 65536, for a system that uses this variant.
var adler = new Adler32C();
byte[] checksum = adler.ComputeHash(largeBlock);
Constructors
Adler32C()
Initializes a new instance of the Adler32C class using the power-of-two modulus (65536).
public Adler32C()
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |