#!/usr/bin/env perl use utf8; ############################################################################### # Program computes a simple checksum of STDIN # # Copyright © 2017 Richard Lesh. All rights reserved. ############################################################################### use Utils; use strict; use warnings; MAIN: { binmode(STDIN); my $c; my $temp = 0; my $count = 0; my $checksum = 0; while (defined($c = Utils::getbyte(*STDIN))) { $temp = $c; $temp = Utils::lshift32($temp, (3 - ($count % 4)) * 8); $checksum = Utils::bitwiseXOr32($checksum, $temp); ++$count; } my $result = Utils::toHex($checksum); print substr($result, -8), "\n"; }