File: Base64.pm

package info (click to toggle)
libbadger-perl 0.16-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,400 kB
  • sloc: perl: 11,004; makefile: 9
file content (113 lines) | stat: -rw-r--r-- 2,350 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#========================================================================
#
# 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__

=head1 NAME

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

=head1 SYNOPSIS

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

=head1 DESCRIPTION

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

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

=head1 METHODS

=head2 encode($data)

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

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

=head2 decode($data)

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

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

=head2 encoder()

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

=head2 decoder()

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

=head1 AUTHOR

Andy Wardley L<http://wardley.org/>

=head1 COPYRIGHT

Copyright (C) 2005-2009 Andy Wardley. All rights reserved.

=head1 SEE ALSO

L<Badger::Codecs>, L<Badger::Codec>, L<MIME::Base64>

=cut

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