The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

Name

SPVM::MIME::Base64 - Encoding and decoding of base64 strings

Synopsys

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

Description

MIME::Base64 is a SPVM module.

This is a porting of MIME::Base64 to SPVM.

This module provides functions to encode and decode strings into and from the base64 encoding specified in RFC 2045 - MIME (Multipurpose Internet Mail Extensions).

Class Methods

The list of class methods.

encode_base64_opt

  static method encode_base64_opt : string ($str : string, $eol : string)

Encode data by calling the encode_base64() function. The first argument is the byte string to encode. The second argument is the line-ending sequence to use. It is optional(undef can be specified) 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 second argument if you do not want the encoded string to be broken into lines.

encode_base64

  static method encode_base64 : string ($str : string)

Alias for the following code using "encode_base64_opt".

  &encode_base64_opt($str, undef);

decode_base64

  static method decode_base64 : string ($str : string)

Decode a base64 string by calling the decode_base64() function. This function takes a single argument which is the string to decode and returns the decoded data.

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_opt

  static method encoded_base64_length_opt : int ($str : string, $eol : string)

Returns the length that the encoded string would have without actually encoding it. This will return the same value as length(&encode_base64_opt($bytes, $eol)), but should be more efficient.

encoded_base64_length

  static method encoded_base64_length : int ($str : string)

Alias for the following code using "encoded_base64_length_opt".

  &encoded_base64_length_opt($str, undef);

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 length(&decode_base64($str)), but should be more efficient.

Repository

https://github.com/yuki-kimoto/SPVM-MIME-Base64

Author

Yuki Kimoto (kimoto.yuki@gmail.com)

Copyright & License

Copyright 2022-2022 Yuki Kimoto, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See Also

SPVM::MIME::QuotedPrint