Subject: | Feature request: as_byte_string() |
Date: | Fri, 2 Dec 2016 03:05:10 -0500 |
To: | bug-math-bigint [...] rt.cpan.org |
From: | Felipe Gasper <felipe [...] felipegasper.com> |
sub as_byte_string {
my ($self) = @_;
my $hex = $self->as_hex();
$hex =~ s<\A0x><>;
#Ensure that we have an even number of hex digits.
if (length($hex) % 2) {
substr($hex, 0, 0) = '0';
}
return pack 'H*', $hex;
}
I’m sure there’s a more efficient means of doing this than the above! It’s useful for crypto stuff and would be great to have upstream.
Thanks!
-Felipe Gasper
Mississauga, Ontario