Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37884515
en ru br
Репозитории ALT

Группа :: Разработка/Perl
Пакет: perl-MIME-Base64-URLSafe

 Главная   Изменения   Спек   Патчи   Исходники   Загрузить   Gear   Bugs and FR  Repocop 

MIME-Base64-URLSafe-0.01/000075500000000000000000000000001171117016100144345ustar00rootroot00000000000000MIME-Base64-URLSafe-0.01/Changes000064400000000000000000000002641171117016100157310ustar00rootroot00000000000000Revision history for Perl extension MIME::Base64::URLSafe.

0.01 Wed Jan 4 18:12:39 2006
- original version; created by h2xs 1.23 with options
-A -X -n MIME::Base64::URLSafe

MIME-Base64-URLSafe-0.01/MANIFEST000064400000000000000000000002461171117016100155670ustar00rootroot00000000000000Changes
Makefile.PL
MANIFEST
README
t/MIME-Base64-URLSafe.t
lib/MIME/Base64/URLSafe.pm
META.yml Module meta-data (added by MakeMaker)
MIME-Base64-URLSafe-0.01/META.yml000064400000000000000000000005471171117016100157130ustar00rootroot00000000000000# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: MIME-Base64-URLSafe
version: 0.01
version_from: lib/MIME/Base64/URLSafe.pm
installdirs: site
requires:
MIME::Base64: 0

distribution_type: module
generated_by: ExtUtils::MakeMaker version 6.17
MIME-Base64-URLSafe-0.01/Makefile.PL000064400000000000000000000005161171117016100164100ustar00rootroot00000000000000use ExtUtils::MakeMaker;

WriteMakefile(NAME => 'MIME::Base64::URLSafe',
VERSION_FROM => 'lib/MIME/Base64/URLSafe.pm',
PREREQ_PM => { MIME::Base64 => 0 },
($] >= 5.005 ?
(ABSTRACT_FROM => 'lib/MIME/Base64/URLSafe.pm',
AUTHOR => 'Kazuho Oku <kazuho ___at___ labs.cybozu.co.jp>') :
()),
);
MIME-Base64-URLSafe-0.01/README000064400000000000000000000013651171117016100153210ustar00rootroot00000000000000MIME-Base64-URLSafe version 0.01
================================

MIME::Base64::URLSafe is an URL-safe base64 encoder / decoder, compatible with python's urlsafe_b64encode / urlsafe_b64decode. The codec uses '-' and '/' instead of '+' and '/', which have special meanings when embedded in URL.

INSTALLATION

To install this module type the following:

perl Makefile.PL
make
make test
make install

DEPENDENCIES

This module requires these other modules and libraries:

MIME::Base64

COPYRIGHT

Copyright (C) 2006 Cybozu Labs, Inc.

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.7 or,
at your option, any later version of Perl 5 you may have available.
MIME-Base64-URLSafe-0.01/lib/000075500000000000000000000000001171117016100152025ustar00rootroot00000000000000MIME-Base64-URLSafe-0.01/lib/MIME/000075500000000000000000000000001171117016100157315ustar00rootroot00000000000000MIME-Base64-URLSafe-0.01/lib/MIME/Base64/000075500000000000000000000000001171117016100167555ustar00rootroot00000000000000MIME-Base64-URLSafe-0.01/lib/MIME/Base64/URLSafe.pm000064400000000000000000000045151171117016100205610ustar00rootroot00000000000000package MIME::Base64::URLSafe;

use strict;
use vars qw(@ISA @EXPORT $VERSION);
use MIME::Base64;

require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(urlsafe_b64encode urlsafe_b64decode);

$VERSION = '0.01';

sub encode ($) {
my $data = encode_base64($_[0], '');
$data =~ tr|+/=|\-_|d;
$data;
}

sub decode ($) {
my $data = $_[0];
# +/ should not be handled, so convert them to invalid chars
# also, remove spaces (\t..\r and SP) so as to calc padding len
$data =~ tr|\-_\t-\x0d |+/|d;
my $mod4 = length($data) % 4;
if ($mod4) {
$data .= substr('====', $mod4);
}
decode_base64($data);
}

*urlsafe_b64encode = \&encode;
*urlsafe_b64decode = \&decode;


1;
__END__

=head1 NAME

MIME::Base64::URLSafe - Perl version of Python's URL-safe base64 codec

=head1 SYNOPSIS

use MIME::Base64::URLSafe;

$encoded = urlsafe_b64encode('Alladdin: open sesame');
$decoded = urlsafe_b64decode($encoded);

=head1 DESCRIPTION

This module is a perl version of python's URL-safe base64 encoder / decoder.

When embedding binary data in URL, it is preferable to use base64 encoding. However, two characters ('+' and '/') used in the standard base64 encoding have special meanings in URLs, often leading to re-encoding with URL-encoding, or worse, interoperability problems.

To overcome the problem, the module provides a variation of base64 codec compatible with python's urlsafe_b64encode / urlsafe_b64decode.

Modification rules from base64:

use '-' and '_' instead of '+' and '/'
no line feeds
no trailing equals (=)

The following functions are provided:

urlsafe_b64encode($str)
urlsafe_b64decode($str)

If you prefer not to import these routines to your namespace, you can call them as:

use MIME::Base64::URLSafe ();
$encoded = MIME::Base64::URLSafe::encode($decoded);
$decoded = MIME::Base64::URLSafe::decode($encoded);

=head1 SEE ALSO

L<MIME::Base64>

Fore more discussion on using base64 encoding in URL applications, see: http://en.wikipedia.org/wiki/Base64#URL_Applications

=head1 AUTHOR

Kazuho Oku E<lt>kazuho ___at___ labs.cybozu.co.jpE<gt>

Copyright (C) 2006 Cybozu Labs, Inc.

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.7 or,
at your option, any later version of Perl 5 you may have available.

=cut
MIME-Base64-URLSafe-0.01/t/000075500000000000000000000000001171117016100146775ustar00rootroot00000000000000MIME-Base64-URLSafe-0.01/t/MIME-Base64-URLSafe.t000064400000000000000000000015431171117016100200770ustar00rootroot00000000000000use strict;

use Test::More tests => 17;

BEGIN { use_ok('MIME::Base64::URLSafe') };


my ($o, $e);


# normal case test

$o = "\0\0\0\0";
$e = 'AAAAAA';
is(urlsafe_b64encode($o), $e);
is(urlsafe_b64decode($e), $o);

$o = "\xff";
$e = '_w';
is(urlsafe_b64encode($o), $e);
is(urlsafe_b64decode($e), $o);

$o = "\xff\xff";
$e = '__8';
is(urlsafe_b64encode($o), $e);
is(urlsafe_b64decode($e), $o);

$o = "\xff\xff\xff";
$e = '____';
is(urlsafe_b64encode($o), $e);
is(urlsafe_b64decode($e), $o);

$o = "\xff\xff\xff\xff";
$e = '_____w';
is(urlsafe_b64encode($o), $e);
is(urlsafe_b64decode($e), $o);

$o = "\xfb";
$e = '-w';
is(urlsafe_b64encode($o), $e);
is(urlsafe_b64decode($e), $o);


# decoder padding test with spaces

is(urlsafe_b64decode(" AA"), "\0");
is(urlsafe_b64decode("\tAA"), "\0");
is(urlsafe_b64decode("\rAA"), "\0");
is(urlsafe_b64decode("\nAA"), "\0");
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin