The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

Name

SPVM::MIME::Base64 - Base64 Encoding/Decoding

Description

The MIME::Base64 class of SPVM has methods for Base64 encoding/decoding.

Usage

  use MIME::Base64;
  
  my $encoded = MIME::Base64->encode_base64('Aladdin:open sesame');
  my $decoded = MIME::Base64->decode_base64($encoded);

Class Methods

encode_base64

  static method encode_base64 : string ($str : string, $eol = undef : string);

Encodes the string $str to a Base64 string, and returns it.

The argument $eol is the line-ending sequence to use. It is optional and defaults to \n.

The returned encoded string is broken into lines of no more than 76 characters each and it will end with $eol unless it is empty.

Pass an empty string as the $eol if you do not want the encoded string to be broken into lines.

decode_base64

  static method decode_base64 : string ($str : string);

Decodes a Base64 string $str to a string, and returns it.

Any character not part of the 65-character base64 subset is silently ignored. Characters occurring after a = padding character are never decoded.

encoded_base64_length

  static method encoded_base64_length : int ($str : string, $eol = undef : string);

Returns the length that the encoded string would have without actually encoding it.

This will return the same value as the length of the returned value of the "encode_base64" method, but should be more efficient.

decoded_base64_length

  static method decoded_base64_length : int ($str : string);

Returns the length that the decoded string would have without actually decoding it.

This will return the same value as the length of the returned value of the "decode_base64" method, but should be more efficient.

Other Modules in This Distribution

See Also

Repository

SPVM::MIME::Base64 - Github

Author

Yuki Kimoto (kimoto.yuki@gmail.com)

Contributors

Yoshiyuki Ito

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License