MIME-Base32-1.02/0000755000000000000000000000000011435256625011707 5ustar rootrootMIME-Base32-1.02/test.pl0000644000000000000000000000400311435253432013211 0ustar rootroot# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### We start with some black magic to print on failure. # Change 1..1 below to 1..last_test_to_print . # (It may become useful if the test is moved to ./t subdirectory.) BEGIN { $| = 1; print "1..10\n"; } END {print "not ok 1\n" unless $loaded;} use MIME::Base32 qw( RFC-3548 ); $loaded = 1; print "ok 1\n"; ######################### End of black magic. # Insert your test code below (better if it prints "ok 13" # (correspondingly "not ok 13") depending on the success of chunk 13 # of the test code): our $TestLevel = 1; our $TestLevels = 10; our $TestLabel = 'this case'; our $TestLabelPrefix = 'TEST:'; sub TestOK() { printf "ok %s\n", $TestLevel; return 1 } sub TestKO() { printf "not ok %s\n", $TestLevel; return 0 } # KO -> k.o. -> knock out sub TestSKIP() { printf "ok %s # SKIP\n", $TestLevel; return 1 } sub TestIt($) { shift() ? TestOK : TestKO } sub TestMSG($) { printf "\t%s%s: '%s'\n", $TestLabelPrefix, $TestLabel, shift() } sub TestMSGf(@) { printf "\t%s%s: ".shift()."\n", $TestLabelPrefix, $TestLabel, @_ } our $GlobalTestString = 'Hallo world, whats new? 1234567890 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ .:!%$@#*()[]{}<>"/ '; our $GlobalEncodedString; our $GlobalDecodedString; $TestLevel++; $TestLabel = 'Encode (RFC-3548 compliant)'; TestIt( eval{ $GlobalEncodedString = MIME::Base32::encode( $GlobalTestString ); TestMSGf "'%s'->'%s'", $GlobalTestString, $GlobalEncodedString; } && !$@ ); $TestLevel++; $TestLabel = 'Decode (RFC-3548 compliant)'; TestIt( eval{ $GlobalDecodedString = MIME::Base32::decode( $GlobalEncodedString ); TestMSGf "'%s'->'%s'", $GlobalEncodedString, $GlobalDecodedString; } && !$@ ); $TestLevel++; $TestLabel = 'Reversibility match'; TestIt( eval{ TestMSG ($GlobalTestString eq $GlobalDecodedString?'PASSED':'FAILED'); } && !$@ ); # unUsed levels are OK TestSKIP while $TestLevels > $TestLevel++; MIME-Base32-1.02/README0000644000000000000000000000222311435254514012561 0ustar rootrootNAME MIME::Base32 - Base32 encoder / decoder SYNOPSIS # RFC forces the [A-Z2-7] RFC-3548 compliant encoding # default encoding [0-9A-V] is for backward compatibility with pre v1.0 use MIME::Base32 qw( RFC ); $encoded = MIME::Base32::encode($text_or_binary_data); $decoded = MIME::Base32::decode($encoded); DESCRIPTION Encode data similar way like MIME::Base64 does. Main purpose is to create encrypted text used as id or key entry typed-or-submitted by user. It is upper/lowercase safe (not sensitive). EXPORT ALLWAYS NOTHING AUTHOR Daniel Peder, sponsored by Infoset s.r.o., Czech Republic http://www.infoset.com COPYRIGHT Copyright (c) 2003-2010 Daniel Peder. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. NOTE Version 1.02 provides minor changes only: - added COPYRIGHT according to FEDORA & DEBIAN community requests - test.pl - extended test string (just for sure ;) SEE ALSO perl(1), MIME::Base64(3pm). MIME-Base32-1.02/MANIFEST0000644000000000000000000000012507766067644013053 0ustar rootrootBase32.pm Makefile.PL MANIFEST This list of files META.yml README test.pl test1.pl MIME-Base32-1.02/test1.pl0000644000000000000000000000356507564705304013316 0ustar rootroot# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### We start with some black magic to print on failure. # Change 1..1 below to 1..last_test_to_print . # (It may become useful if the test is moved to ./t subdirectory.) BEGIN { $| = 1; print "1..10\n"; } END {print "not ok 1\n" unless $loaded;} use MIME::Base32; $loaded = 1; print "ok 1\n"; ######################### End of black magic. # Insert your test code below (better if it prints "ok 13" # (correspondingly "not ok 13") depending on the success of chunk 13 # of the test code): our $TestLevel = 1; our $TestLevels = 10; our $TestLabel = 'this case'; our $TestLabelPrefix = 'TEST:'; sub TestOK() { printf "ok %s\n", $TestLevel; return 1 } sub TestKO() { printf "not ok %s\n", $TestLevel; return 0 } # KO -> k.o. -> knock out sub TestSKIP() { printf "ok %s # SKIP\n", $TestLevel; return 1 } sub TestIt($) { shift() ? TestOK : TestKO } sub TestMSG($) { printf "\t%s%s: '%s'\n", $TestLabelPrefix, $TestLabel, shift() } sub TestMSGf(@) { printf "\t%s%s: ".shift()."\n", $TestLabelPrefix, $TestLabel, @_ } our $GlobalTestString = 'Hallo world, whats new?'; our $GlobalEncodedString; our $GlobalDecodedString; $TestLevel++; $TestLabel = 'Encode'; TestIt( eval{ $GlobalEncodedString = MIME::Base32::encode( $GlobalTestString ); TestMSGf "'%s'->'%s'", $GlobalTestString, $GlobalEncodedString; } && !$@ ); $TestLevel++; $TestLabel = 'Decode'; TestIt( eval{ $GlobalDecodedString = MIME::Base32::decode( $GlobalEncodedString ); TestMSGf "'%s'->'%s'", $GlobalEncodedString, $GlobalDecodedString; } && !$@ ); $TestLevel++; $TestLabel = 'Reversibility match'; TestIt( eval{ TestMSG ($GlobalTestString eq $GlobalDecodedString?'PASSED':'FAILED'); } && !$@ ); # unUsed levels are OK TestSKIP while $TestLevels > $TestLevel++; MIME-Base32-1.02/Makefile.PL0000644000000000000000000000115107573431571013662 0ustar rootrootuse ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( 'NAME' => 'MIME::Base32', 'VERSION_FROM' => 'Base32.pm', # finds $VERSION 'PREREQ_PM' => {}, # e.g., Module::Name => 1.1 ($] >= 5.005 ? ( ABSTRACT_FROM => 'Base32.pm', AUTHOR => 'Daniel Peder ', ) : ()), ); sub MY::postamble { q{ docs : README README: Base32.pm pod2text --loose Base32.pm > README xdist: [ -f MANIFEST ] && rm -f MANIFEST ; make realclean docs manifest tardist; perl Makefile.PL }; } MIME-Base32-1.02/Base32.pm0000644000000000000000000000562411435254532013266 0ustar rootrootpackage MIME::Base32; require 5.005_62; use strict; use warnings; use vars qw( $VERSION ); $VERSION = '1.02'; # minor changes : added COPYRIGHT according to community request; test.pl - extended test string sub import { my( $pkg, $arg )=@_; if( defined($arg) && $arg =~ /rfc|3548/i ) { *encode = \&encode_rfc3548; *decode = \&decode_rfc3548; } else { *encode = \&encode_09AV; *decode = \&decode_09AV; } } sub encode_rfc3548{ # base32: # # modified base64 algorithm with # 32 characters set: A - Z 2 - 7 compliant with: RFC-3548 # $_ = shift @_; my( $buffer, $l, $e ); $_=unpack('B*', $_); s/(.....)/000$1/g; $l=length; if ($l & 7) { $e = substr($_, $l & ~7); $_ = substr($_, 0, $l & ~7); $_ .= "000$e" . '0' x (5 - length $e); } $_=pack('B*', $_); tr|\0-\37|A-Z2-7|; $_; } sub decode_rfc3548{ $_ = shift; my( $l ); tr|A-Z2-7|\0-\37|; $_=unpack('B*', $_); s/000(.....)/$1/g; $l=length; # pouzije pouze platnou delku retezce $_=substr($_, 0, $l & ~7) if $l & 7; $_=pack('B*', $_); } sub encode_09AV{ # base32: # # modified base64 algorithm with # 32 characters set: [0-9A-V] pre 1.00 backward compatibility # $_ = shift @_; my( $buffer, $l, $e ); $_=unpack('B*', $_); s/(.....)/000$1/g; $l=length; if ($l & 7) { $e = substr($_, $l & ~7); $_ = substr($_, 0, $l & ~7); $_ .= "000$e" . '0' x (5 - length $e); } $_=pack('B*', $_); tr|\0-\37|0-9A-V|; $_; } sub decode_09AV{ $_ = shift; my( $l ); tr|0-9A-V|\0-\37|; $_=unpack('B*', $_); s/000(.....)/$1/g; $l=length; # pouzije pouze platnou delku retezce $_=substr($_, 0, $l & ~7) if $l & 7; $_=pack('B*', $_); } 1; __END__ =head1 NAME MIME::Base32 - Base32 encoder / decoder =head1 SYNOPSIS # RFC forces the [A-Z2-7] RFC-3548 compliant encoding # default encoding [0-9A-V] is for backward compatibility with pre v1.0 use MIME::Base32 qw( RFC ); $encoded = MIME::Base32::encode($text_or_binary_data); $decoded = MIME::Base32::decode($encoded); =head1 DESCRIPTION Encode data similar way like MIME::Base64 does. Main purpose is to create encrypted text used as id or key entry typed-or-submitted by user. It is upper/lowercase safe (not sensitive). =head1 EXPORT ALLWAYS NOTHING =head1 AUTHOR Daniel Peder, sponsored by Infoset s.r.o., Czech Republic http://www.infoset.com =head1 COPYRIGHT Copyright (c) 2003-2010 Daniel Peder. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 NOTE Version 1.02 provides minor changes only: - added COPYRIGHT according to FEDORA & DEBIAN community requests - test.pl - extended test string (just for sure ;) =head1 SEE ALSO perl(1), MIME::Base64(3pm). =cut MIME-Base32-1.02/META.yml0000644000000000000000000000045111435256625013160 0ustar rootroot# http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: MIME-Base32 version: 1.02 version_from: Base32.pm installdirs: site requires: distribution_type: module generated_by: ExtUtils::MakeMaker version 6.16