Fletcher32 Class
Definition
Computes the hash for the input data using the Fletcher-32 hash algorithm. This variant performs a
non-cryptographic checksum calculation using two 16-bit accumulators to efficiently detect errors in byte sequences.
This class cannot be inherited.
public sealed class Fletcher32 : Fletcher, IResumableHashAlgorithm
- Inheritance
-
Fletcher32
- 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
Fletcher32 is a lightweight checksum algorithm that produces a 32-bit output by iteratively processing input bytes using two 16-bit rolling sums. It was introduced by Brian Kernighan and Dennis Ritchie and is commonly used in networking, file validation, and embedded systems where error detection is required but cryptographic strength is not.
Parameters at a glance.
- Output size: 32 bits (4 bytes).
- Accumulator width: two 16-bit rolling sums (A and B).
- Modulus:
65535.
When to choose Fletcher32. The general-purpose Fletcher variant - TCP/UDP-style packet checks, file integrity in streaming pipelines, and ZFS-class block sums. Faster than CRC at the cost of weaker burst-error coverage; pick Crc with a 32-bit standard such as CRC32_ISOHDLC when error-detection guarantees matter more than throughput.
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;
var f32 = new Fletcher32();
byte[] checksum = f32.ComputeHash(payload);
Constructors
Fletcher32()
Initializes a new instance of the Fletcher32 class with a 32-bit hash size.
public Fletcher32()
Methods
CreateEmpty()
Creates a new, empty instance of the concrete Fletcher variant. Replaces the former new TSelf() CRTP
construction as the factory the base Clone() uses to snapshot running state.
protected override Fletcher CreateEmpty()
Returns
- Fletcher
A fresh instance of the derived variant with default accumulator state.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |