Add built local::lib
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / Object / Signature.pm
CommitLineData
3fea05b9 1package Object::Signature;
2
3use 5.005;
4use strict;
5
6use vars qw{$VERSION};
7BEGIN {
8 $VERSION = '1.05';
9}
10
11# If prefork is installed, use it
12eval "use prefork 'Storable';";
13eval "use prefork 'Digest::MD5';";
14
15sub signature {
16 require Storable;
17 require Digest::MD5;
18 local $Storable::canonical = 1;
19 Digest::MD5::md5_hex(
20 Storable::nfreeze(shift)
21 );
22}
23
241;
25
26__END__
27
28=pod
29
30=head1 NAME
31
32Signature - Generate cryptographic signatures for objects
33
34=head1 SYNOPSIS
35
36 # In your module
37 package My::Module
38 use base 'Object::Signature';
39
40 # In outside code
41 my $Object = My::Module->new;
42 print "Object Signature: " . $Object->signature;
43
44=head1 DESCRIPTION
45
46L<Object::Signature> is an abstract base class that you can inherit from in
47order to allow your objects to generate unique cryptographic signatures.
48
49The method used to generate the signature is based on L<Storable> and
50L<Digest::MD5>. The object is fed to C<Storable::nfreeze> to get a string,
51which is then passed to L<Digest::MD5::md5_hex> to get a unique 32
52character hexidecimal signature.
53
54=head1 METHODS
55
56=head2 signature
57
58The C<signature> method is the only method added to your class, and will
59generate a unique 32 hexidecimal signature for any object it is called on.
60
61=head1 SUPPORT
62
63All bugs should be filed via the bug tracker at
64
65L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Object-Signature>
66
67For other issues, or commercial enhancement or support, contact the author.
68
69=head1 TO DO
70
71=head2 Incremental Generation
72
73Currently has to generate the entire Storable string before digesting
74it. Would be nice if there was a way to incrementally Storablise and Digest
75in one pass so that it becomes much more memory efficient for large objects.
76
77=head2 Strengthen the Digest Algorithm
78
79Once the current (as of 2005) hashing controversy settles down, consider
80selecting a newer and more powerful hashing algorithm to replace MD5. Or
81offer alternatives depending on how important the security situation is,
82as MD5 is B<very> fast (90 meg a second) and many more-secure ones are a
83lot slower (more than 10 times slower in some cases).
84
85On our side is the fact we use Storable. It should be B<much> harder to create
86collisions when you don't control the string, only the structure B<before>
87it goes through Storable.
88
89=head1 AUTHORS
90
91Adam Kennedy E<lt>adamk@cpan.orgE<gt>
92
93=head1 COPYRIGHT
94
95Copyright 2004 - 2006 Adam Kennedy.
96
97This program is free software; you can redistribute
98it and/or modify it under the same terms as Perl itself.
99
100The full text of the license can be found in the
101LICENSE file included with this module.
102
103=cut