Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: How to generate 64-character length lines in base64?

by thundergnat (Deacon)
on Mar 19, 2013 at 13:45 UTC ( [id://1024301]=note: print w/replies, xml ) Need Help??


in reply to How to generate 64-character length lines in base64?

Specify a blank eol character when you encode it, then break it up however you want.

Update: oops, removed bogus double quotes

use MIME::Base64; my $str = 'Whatever'; my $encoded = encode_base64($str, ''); $encoded =~ s/(.{1,64})/$1\n/g; print $encoded;

Replies are listed 'Best First'.
Re^2: How to generate 64-character length lines in base64?
by rmichael (Initiate) on Mar 19, 2013 at 16:31 UTC

    Thank you!

    I did wonder about this, but was unsure about '=' padding if/when required. encode with the default EOL would handle that for me, I believe. Perhaps breaking it up myself could necessitate change some line endings?

    I'll read a few more spec details and play with this.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1024301]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-03-28 19:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found