Table of Contents

Fletcher16 Class

Definition

Namespace
Bodu.IO.Hashing.Checksums
Assembly
Bodu.IO.Hashing.dll
Package
Bodu.IO.Hashing 1.0.0
Source
Fletcher.16.cs

Computes the hash for the input data using the Fletcher-16 hash algorithm. This variant performs a non-cryptographic checksum calculation using two 8-bit accumulators to detect errors in small byte sequences. This class cannot be inherited.

public sealed class Fletcher16 : Fletcher, IResumableHashAlgorithm
Inheritance
Fletcher16
Implements
Inherited Members
Extension Methods

Remarks

Fletcher16 is a lightweight checksum algorithm that produces a 16-bit output by iteratively summing input bytes using two rolling accumulators. It was introduced by Brian Kernighan and Dennis Ritchie and is commonly used in network protocols, embedded systems, and file integrity checks where performance and simplicity are preferred over cryptographic strength.

Parameters at a glance.

  • Output size: 16 bits (2 bytes).
  • Accumulator width: two 8-bit rolling sums (A and B).
  • Modulus: 255.

When to choose Fletcher16. Pick Fletcher16 for embedded protocols and short-frame links where 16 bits is enough - Modbus ASCII, RPL message integrity, and similar resource-constrained settings. For general file integrity prefer Fletcher32; for stronger error-detection guarantees prefer a 16-bit CRC such as Crc with CRC16_MODBUS.

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 f16 = new Fletcher16();
byte[] checksum = f16.ComputeHash(framePayload);

Constructors

Fletcher16()

Initializes a new instance of the Fletcher16 class with a 16-bit hash size.

public Fletcher16()

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

ProductVersions
.NET8, 10

See Also