Use this when a text file has been copied through a browser, terminal, note, chat, OCR, or another path that may alter individual lines. It provides a short diagnostic fingerprint for every logical line, grouped eight per output row.
perl -ne '
s/\r?\n\z//;
($a,$b)=(0,0);
for $c (unpack "C*",$_) {
$a=($a+$c)%255;
$b=($b+$a)%255;
}
$start=$. unless @checks;
push @checks,sprintf("%02x%02x",$b,$a);
if (@checks==8) {
printf "%04d %s\n",
$start,
join(" ",@checks);
@checks=();
}
END {
printf "%04d %s\n",
$start,
join(" ",@checks)
if @checks;
}
' FILE
0001 ea7c 0000 2952 0000 56f3 2fd9 9d9f 2681
0009 83a1 1130 0000 c42e 719a 4d08 d8b0 0000
The leading value is the source line number represented by the first checksum on that row. Each following four-hex-digit value describes one line. A value of 0000 normally represents an empty line. CRLF and LF endings are deliberately treated as equivalent.
Use it when a normal whole-file checksum differs and you need to distinguish harmless newline changes from missing, inserted, wrapped, or edited lines. It is also useful when transferring the full file back for comparison would be inconvenient.
This is a small Fletcher-style diagnostic checksum, not a cryptographic integrity check. Collisions are possible. Continue to use SHA-256 for archives, binaries, security-sensitive verification, and final exact-transfer confirmation. Use these compact checksums to locate text differences, not to prove authenticity.
1. Compare SHA-256 first. 2. If it differs, compare the compact per-line output. 3. Correct any substantive line differences. 4. Accept deliberate newline-only differences or regenerate an exact copy when byte identity is required.