Hawkynt

Twos-Complement-8

8-bit two’s complement checksum. Sums all bytes modulo 256, then returns two’s complement (negate). Verification: sum of all data bytes plus checksum equals zero (mod 256).

Properties

Property Value
Category Checksums
Sub-category Twos Complement
Security status 🎓 Educational Only
Complexity Beginner
Inventor Unknown (fundamental technique)
Year 1960
Origin Not specified
Source algorithms/checksum/complement.js

Security

Status: 🎓 Educational Only

No vulnerabilities are recorded for this implementation.

Notes

Documentation

References

Test vectors

3 vectors ship with this algorithm and run in the test suite. Byte values are hexadecimal.

Vector 1 — Byte sum 0x06, 8-bit complement 0xFA

Field Value
input 010203
expected fa

Vector 2 — Serial protocol example

Field Value
input 25623f52
expected e8

Vector 3 — Byte sum 0xFF, 8-bit complement 0x01

Field Value
input ff
expected 01

← All algorithms