For example:
#!/usr/local/bin/perl -w use MIME::Base64; my $stone = 'purplebarneystone'; my $b64 = encode_base64($stone); print "$b64\n";
MIME::Base64 implements the following functions, both of which are exported.
decode_base64 |
decode_base64(string)
Unpacks the base64-encoded string and returns the decoded data. In addition, decode_base64 ignores any character that's not part of the recognized 65-character base64 subset.
encode_base64 |
encode_base64(string, [end_of_line])
Base64-encodes string with the optional end_of_line argument. To base64-encode a JPEG image that lives in a file, you should specify end_of_line, since encode_base64 returns base64-encoded content that's broken down into 76 characters per line. If you do not want the 76-character breaks to be imposed on you, set end_of_line to an empty string ("").
Copyright © 2002 O'Reilly & Associates. All rights reserved.