[ale] Base64 encoding in Perl

Christopher Fowler cfowler at outpostsentinel.com
Mon Feb 14 12:20:01 EST 2005


Thanks fletch.  My concern was the final '==' at the end of the data.  I
was under the assumption that I had to read all the data in then feed it
to the encoder.

I have created a 9M file that is the output of my program.  How do I
reassemble this in perl.  Do I need to read it all into a buffer and
feed it to the decoder after I strip the NL's off?

On the perl side I'm simply just using it to test my XML-RPC C code on
my embedded device.  The reason I have a 9m file is that I intend to
feed software upgrades via XML-RPC.

On Mon, 2005-02-14 at 12:03, Fletch wrote:
> >>>>> "Christopher" == Christopher Fowler <cfowler at outpostsentinel.com> writes:
> 
>     Christopher> I'm trying to use MIME::Base64::encode to encode a 9m
>     Christopher> binary file into Base64.  I'm using sysopen and
>     Christopher> sysread on the file but I'm not sure how to append
>     Christopher> the result of the read into a data buffer.
> 
> If you check down in the "EXAMPLES" section of "perldoc MIME::Base64"
> it says you should just read and encode using a multiple of 57 bytes
> to completely fill up a single base64 line:
> 
>           use MIME::Base64 qw(encode_base64);
> 
>           open(FILE, "/var/log/wtmp") or die "$!";
>           while (read(FILE, $buf, 60*57)) {
>               print encode_base64($buf);
>           }



More information about the Ale mailing list