use strict; use warnings; use Data::Dump; use Math::BigInt; my $string = '1677259342285725925376'; my $n = Math::BigInt->new($string); my @bytes = map { ord } split //, $n->to_bytes(); @bytes = map { $_ >= 128 ? $_ - 256 : $_ } @bytes; dd \@bytes;