ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Digest-Hashcash/Hashcash.pm
(Generate patch)

Comparing Digest-Hashcash/Hashcash.pm (file contents):
Revision 1.3 by root, Sun May 30 21:59:43 2004 UTC vs.
Revision 1.7 by root, Wed Jul 22 10:33:08 2015 UTC

27 27
28require XSLoader; 28require XSLoader;
29 29
30no warnings; 30no warnings;
31 31
32$VERSION = 0.02; 32$VERSION = 1.1;
33 33
34XSLoader::load Digest::Hashcash, $VERSION; 34XSLoader::load Digest::Hashcash, $VERSION;
35 35
36=item $secs = estimate_time $size 36=item $secs = estimate_time $size
37 37
70 my ($time, $min) = @_; 70 my ($time, $min) = @_;
71 $time = (log $time * $rounds) / log 2; 71 $time = (log $time * $rounds) / log 2;
72 $time < $min ? $min : int $time; 72 $time < $min ? $min : int $time;
73} 73}
74 74
75=item $cipher = new [param => value...] 75=item $cipher = new Digest::Hashcash [param => value...]
76 76
77=over 4 77=over 4
78 78
79=item size => 18 79=item size => 18
80 80
101The timestamp to use. A value of 0 (the default) means to use the current 101The timestamp to use. A value of 0 (the default) means to use the current
102time. 102time.
103 103
104=back 104=back
105 105
106=item $token = $cipher->hash($data [, param => value...]) 106=item $token = $cipher->hash ($data [, param => value...])
107 107
108Creates and returns a new token. This can take some time. 108Creates and returns a new token. This can take some time.
109 109
110Any additional parameters are interpreted the same way as arguments to 110Any additional parameters are interpreted the same way as arguments to
111C<new>. 111C<new>.
112 112
113=item $prefix = $cipher->verify($token [, param => value...])) 113=item $prefix = $cipher->verify ($token [, param => value...]))
114 114
115Checks the given token and returns true if the token has the minimum 115Checks the given token and returns true if the token has the minimum
116number of prefix bits, or false otherwise. The value returned is actually 116number of prefix bits, or false otherwise. The value returned is actually
117the number of collisions, so to find the number of collisions bits specify 117the number of collisions, so to find the number of collisions bits specify
118C<< collisions => 0 >>. 118C<< collisions => 0 >>.
119 119
120Any additional parameters are interpreted the same way as arguments to 120Any additional parameters are interpreted the same way as arguments to
121C<new>. 121C<new>.
122 122
123=item $resource = $cipher->resource($token) 123=item $resource = $cipher->resource ($token)
124 124
125Returns the resource part, or C<undef>. 125Returns the resource part, or C<undef>.
126 126
127=item $tstamp = $ciper->timestamp($token) 127=item $tstamp = $ciper->timestamp ($token)
128 128
129Returns the timestamp part (in the same format as perl's C<time>), or 129Returns the timestamp part (in the same format as perl's C<time>), or
130C<undef>. 130C<undef>.
131 131
132=back 132=back
186 186
187=head1 SEE ALSO 187=head1 SEE ALSO
188 188
189L<http://www.hashcash.org>. 189L<http://www.hashcash.org>.
190 190
191=head1 SUPPORT FOR THE PERL MULTICORE SPECIFICATION
192
193This module supports the perl multicore specification
194(<http://perlmulticore.schmorp.de/>) for token generation of any length
195and size.
196
191=head1 BUGS 197=head1 BUGS
192 198
193 * There is a y2k+100 problem, as I always assume the same as Time::Local. 199 * There is a y2k+100 problem, as I always assume the same as Time::Local.
194 This is a problem with the hashcash specification, which specifies 200 This is a problem with the hashcash specification, which specifies
195 years as 2 digits :( 201 years as 2 digits :(
196 202
197=head1 AUTHOR 203=head1 AUTHOR
198 204
199 Marc Lehmann <pcg@goof.com> 205 Marc Lehmann <schmorp@schmorp.de>
200 http://home.schmorp.de 206 http://home.schmorp.de
201 207
202=cut 208=cut
203 209
2041; 2101;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines