fletcher-pure
fletcher-pure — zero-dependency pure-stdlib Fletcher-16 checksum per RFC 3309 / ISO/IEC 3309.
No dependencies. No C extension. Pure Python stdlib — runs anywhere Python runs.
Quick Start
pip install -e .
from fletcher_pure import checksum, verify
c = checksum(b"Hello") # int in [0, 65535]
ok = verify(b"Hello", 0x1A3F) # bool
Why fletcher-pure?
Embedded systems engineers and serverless Python developers working on legacy protocol parsers (X.25, ISO/IEC 3309) need a pure-Fletcher-16 checksum utility without pulling in a heavy library. The crcmod package weighs several MB and requires C compilation; fletcher on PyPI has unknown runtime deps.
fletcher-pure provides:
- Zero runtime dependencies — pure Python stdlib only
- RFC 3309 / ISO/IEC 3309 compliant Fletcher-16 mod-255
- Arbitrary input size — Python int arithmetic never overflows
- Typing included — full type annotations
Key Features
checksum(data: bytes) -> int— Fletcher-16 mod-255, returns int in [0, 65535]verify(data: bytes, expected: int) -> bool— True iff checksum matches- Zero pip dependencies at runtime
- Works on inputs up to 65535 bytes (and beyond) without overflow
- Full type annotations
- 100% test coverage of acceptance criteria
API Reference
checksum(data: bytes) -> int
Compute the Fletcher-16 checksum (mod 255) of data.
checksum(b"") # 0
checksum(b"\x00") # 0 (c0=c1=0 initialization per RFC 3309 §5.1)
checksum(b"\x01\x02") # 1027
checksum(b"\xff\xff") # 0 (mod-255 wrap)
checksum(b"123456789") # 0x1EDE = 7902
verify(data: bytes, expected: int) -> bool
Return True if checksum(data) == expected, False otherwise.
verify(b"Hello", checksum(b"Hello")) # True
verify(b"Hello", checksum(b"Hello") ^ 0x0001) # False (corruption detected)
verify(b"", 0) # True
Raises TypeError if data is not bytes or bytearray.
CLI
No CLI is provided. Use as a library:
from fletcher_pure import checksum, verify
Limitations
- Fletcher-16 is not cryptographically secure — use SHA-256 for security purposes.
- Collisions are possible for larger inputs (birthday paradox applies).
- No streaming / chunked API — entire input must fit in memory.
verifydoes not acceptmemoryview(onlybytesandbytearray).
Non-Goals
- No CRC32, Adler-32, or other checksum algorithms.
- No CLI tool.
- No native/C extension for speed.
- No support for Python < 3.8.
Install
pip install -e .
For development:
git clone https://github.com/prasad-a-abhishek/fletcher-pure.git
cd fletcher-pure
pip install -e .
pytest
License
MIT License — see LICENSE file.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fletcher_pure-0.1.0.tar.gz.
File metadata
- Download URL: fletcher_pure-0.1.0.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c79fecb0463bab876fe6f4743cba5d0042bef1001e5a9e32ba8fb1a754533c6f
|
|
| MD5 |
18f4cf8339714c9fff91a44c6956a603
|
|
| BLAKE2b-256 |
08c5a78389e72043cc8e8ca84d98d847f81dbd93e4f2c09adf60c13a95e8930e
|
File details
Details for the file fletcher_pure-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fletcher_pure-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e666482dcdfd8a2d7423685fe7d848c6c38defdc35e419e99a660ab8d2c5692f
|
|
| MD5 |
8032ccf5dc682d9f6453b3a0001193d8
|
|
| BLAKE2b-256 |
739c9824ee62baa4427fdd1b3cb53456a20e5bd916a646a3cda4f97920a62462
|