sub bytearray_to_bigint { my $result = Math::BigInt->new('0'); while (@_) { $result <<= 8; # was *= 256; $result += pop; } $result; }