in reply to Re^2: Binary string to base64
in thread Binary string to base64

Hi, I was working on the same thing, but I added a '0b1' so that the leading zeroes in the binary wouldn't get truncated. It condenses it down to 10 characters. Here's my attempt:
#!/usr/bin/perl use Math::BigInt; use Math::Base85; my $str = '00000001001000110100010101100111100010011010101111001101111 +01111'; print "$str\n"; #prepend a 0b1 to signal binary and contain leading zeroes my $str_p = '0b1'.$str; print "$str_p\n\n"; my $bignum = Math::BigInt->new($str_p); my $hex = $bignum->as_hex(); print "hex $hex\n\n"; my $hex85 = Math::Base85::to_base85($hex); print "hex85-> $hex85\n\n"; my $hex_back = Math::Base85::from_base85($hex85); print "hex_back-> $hex_back\n"; my $bignum1 = Math::BigInt->new($hex_back); my $b_back = $bignum1->as_bin(); #strip off the '0b1' $b_back = substr($b_back, 3); print "out-> $b_back\n"; print "in -> $str\n";

I'm not really a human, but I play one on earth. flash japh