Badger::Codec::Base64 - encode/decode data using MIME::Base64


Badger documentation Contained in the Badger distribution.

Index


Code Index:

NAME

Top

Badger::Codec::Base64 - encode/decode data using MIME::Base64

SYNOPSIS

Top

    use Badger::Codec::Base64;
    my $codec   = Badger::Codec::Base64->new();
    my $encoded = $codec->encode("Hello World");
    my $decoded = $codec->decode($encoded);

DESCRIPTION

Top

This module implements a subclass of Badger::Codec which uses the encode_base64 and decode_base64 subroutines provided by the MIME::Base64 module to encode and decode data.

It a very thin wrapper around the MIME::Base64 module and offers no functional advantage over it. It exist only to provide a consistent API with other Badger::Codec modules.

METHODS

Top

encode($data)

Encodes the data referenced by the first argument using encode_base64().

    $encoded = Badger::Codec::Base64->encode($data);   

decode($data)

Decodes the encoded data passed as the first argument using decode_base64().

    $decoded = Badger::Codec::Base64->decode($encoded);

encoder()

This method returns a reference to the real subroutine that's doing all the encoding work, i.e. the encode_base64() method in MIME::Base64.

decoder()

This method returns a reference to the real subroutine that's doing all the decoding work, i.e. the decode_base64() method in MIME::Base64.

AUTHOR

Top

Andy Wardley http://wardley.org/

COPYRIGHT

Top

SEE ALSO

Top

Badger::Codecs, Badger::Codec, MIME::Base64


Badger documentation Contained in the Badger distribution.

#========================================================================
#
# Badger::Codec::Base64
#
# DESCRIPTION
#   Codec module for encoding/decoding Base64
#
# AUTHOR
#   Andy Wardley   <abw@wardley.org>
#
#========================================================================

package Badger::Codec::Base64;

use Badger::Class
    version => 0.01,
    base    => 'Badger::Codec';

use MIME::Base64;

sub encode {
    my $self = shift;
    encode_base64(shift);
}

sub decode {
    my $self = shift;
    decode_base64(shift);
}

# shortcuts straight to the real encoder/decoder subs for efficient aliasing

sub encoder {
    \&encode_base64;
}

sub decoder {
    \&decode_base64;
}


1;


__END__

# Local Variables:
# mode: Perl
# perl-indent-level: 4
# indent-tabs-mode: nil
# End:
#
# vim: expandtab shiftwidth=4: