Data-Token-0.0.3/0000755000076500007650000000000011015456226013067 5ustar scottpscottpData-Token-0.0.3/Build.PL0000444000076500007650000000074411015456226014366 0ustar scottpscottpuse strict; use warnings; use Module::Build; my $builder = Module::Build->new( module_name => 'Data::Token', license => 'perl', dist_author => 'Scott Penrose ', dist_version_from => 'lib/Data/Token.pm', requires => { 'Test::More' => 0, 'version' => 0, 'Data::UUID' => 0, 'Digest::MD5' => 0, }, add_to_cleanup => [ 'Data-Token-*' ], ); $builder->create_build_script(); Data-Token-0.0.3/Changes0000444000076500007650000000013211015456226014354 0ustar scottpscottpRevision history for Data-Token 0.0.1 Thu May 22 16:35:23 2008 Initial release. Data-Token-0.0.3/lib/0000755000076500007650000000000011015456226013635 5ustar scottpscottpData-Token-0.0.3/lib/Data/0000755000076500007650000000000011015456226014506 5ustar scottpscottpData-Token-0.0.3/lib/Data/Token.pm0000444000076500007650000000551211015456226016125 0ustar scottpscottppackage Data::Token; use warnings; use strict; use version; our $VERSION = qv('0.0.3'); use Data::UUID; use Digest::MD5 qw(md5_hex); use base qw/Exporter/; our @EXPORT = qw/token/; sub token { our $uuid ||= new Data::UUID; our $secret ||= rand(time); return md5_hex($uuid->create_str() . $secret); } 1; # Magic true value required at end of module __END__ =head1 NAME Data::Token - Generate an unpredictable unique token =head1 VERSION This document describes Data::Token version 0.0.1 =head1 SYNOPSIS use Data::Token; print token; =head1 DESCRIPTION This library exports a single method 'token' which can be used to generate a unique and unpredictable token. =head1 INTERFACE =head2 token Return a unique token. =head1 DIAGNOSTICS =over =item C<< Error message here, perhaps with %s placeholders >> =item C<< Another error message here >> =back =head1 CONFIGURATION AND ENVIRONMENT Data::Token requires no configuration files or environment variables. =head1 DEPENDENCIES Uses Data::UUID to create the initial unique number and md5 to generate the unpredictability. =head1 INCOMPATIBILITIES None reported. =head1 BUGS AND LIMITATIONS No bugs have been reported. Please report any bugs or feature requests to C, or through the web interface at L. =head1 AUTHOR Scott Penrose C<< >> =head1 LICENCE AND COPYRIGHT Copyright (c) 2008, Scott Penrose C<< >>. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Data-Token-0.0.3/MANIFEST0000444000076500007650000000020411015456226014212 0ustar scottpscottpBuild.PL Changes MANIFEST README lib/Data/Token.pm t/00.load.t t/perlcritic.t t/pod-coverage.t t/pod.t t/token.t t/basic.t META.yml Data-Token-0.0.3/META.yml0000444000076500007650000000073011015456226014336 0ustar scottpscottp--- name: Data-Token version: 0.0.3 author: - 'Scott Penrose ' abstract: Generate an unpredictable unique token license: perl resources: license: http://dev.perl.org/licenses/ requires: Data::UUID: 0 Digest::MD5: 0 Test::More: 0 version: 0 provides: Data::Token: file: lib/Data/Token.pm version: 0.0.3 generated_by: Module::Build version 0.2808 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.2.html version: 1.2 Data-Token-0.0.3/README0000444000076500007650000000172011015456226013745 0ustar scottpscottpData-Token version 0.0.1 [ REPLACE THIS... The README is used to introduce the module and provide instructions on how to install the module, any machine dependencies it may have (for example C compilers and installed libraries) and any other information that should be understood before the module is installed. A README file is required for CPAN modules since CPAN extracts the README file from a module distribution so that people browsing the archive can use it get an idea of the modules uses. It is usually a good idea to provide version information here so that people can decide whether fixes for the module are worth downloading. ] INSTALLATION To install this module, run the following commands: perl Build.PL ./Build ./Build test ./Build install DEPENDENCIES None. COPYRIGHT AND LICENCE Copyright (C) 2008, Scott Penrose This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Data-Token-0.0.3/t/0000755000076500007650000000000011015456226013332 5ustar scottpscottpData-Token-0.0.3/t/00.load.t0000444000076500007650000000016511015456226014654 0ustar scottpscottpuse Test::More tests => 1; BEGIN { use_ok( 'Data::Token' ); } diag( "Testing Data::Token $Data::Token::VERSION" ); Data-Token-0.0.3/t/basic.t0000444000076500007650000000013311015456226014573 0ustar scottpscottpuse Test::More tests => 2; BEGIN { use_ok( 'Data::Token' ); } ok(token(), "Get a token"); Data-Token-0.0.3/t/perlcritic.t0000444000076500007650000000027511015456226015661 0ustar scottpscottp#!perl if (!require Test::Perl::Critic) { Test::More::plan( skip_all => "Test::Perl::Critic required for testing PBP compliance" ); } Test::Perl::Critic::all_critic_ok(); Data-Token-0.0.3/t/pod-coverage.t0000444000076500007650000000025411015456226016071 0ustar scottpscottp#!perl -T use Test::More; eval "use Test::Pod::Coverage 1.04"; plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@; all_pod_coverage_ok(); Data-Token-0.0.3/t/pod.t0000444000076500007650000000021411015456226014274 0ustar scottpscottp#!perl -T use Test::More; eval "use Test::Pod 1.14"; plan skip_all => "Test::Pod 1.14 required for testing POD" if $@; all_pod_files_ok(); Data-Token-0.0.3/t/token.t0000444000076500007650000000112011015456226014627 0ustar scottpscottp# $generate * 3 # +2 (load and number generated) use Test::More tests => 30002; my $generate = 10000; BEGIN { use_ok( 'Data::Token' ); } # Make sure they are uniue my %dups = (); for my $i (1..$generate) { my $t = token; if (!exists($dups{$t})) { $dups{$t} = 0 } $dups{$t} = $dups{$t} + 1; } cmp_ok (scalar(keys %dups), '==', $generate, "Invalid number of generated tokens (" . scalar(keys %dups) . " of $generate)"); foreach my $token (keys %dups) { cmp_ok($dups{$token}, '==', 1, "Valid only once !"); ok (length($token) > 5); # Complex enough? like ($token, qr/[a-zA-Z0-9]/); }