… | |
… | |
27 | |
27 | |
28 | require XSLoader; |
28 | require XSLoader; |
29 | |
29 | |
30 | no warnings; |
30 | no warnings; |
31 | |
31 | |
32 | $VERSION = 0.02; |
32 | $VERSION = 1.1; |
33 | |
33 | |
34 | XSLoader::load Digest::Hashcash, $VERSION; |
34 | XSLoader::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 | |
… | |
… | |
101 | The timestamp to use. A value of 0 (the default) means to use the current |
101 | The timestamp to use. A value of 0 (the default) means to use the current |
102 | time. |
102 | time. |
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 | |
108 | Creates and returns a new token. This can take some time. |
108 | Creates and returns a new token. This can take some time. |
109 | |
109 | |
110 | Any additional parameters are interpreted the same way as arguments to |
110 | Any additional parameters are interpreted the same way as arguments to |
111 | C<new>. |
111 | C<new>. |
112 | |
112 | |
113 | =item $prefix = $cipher->verify($token [, param => value...])) |
113 | =item $prefix = $cipher->verify ($token [, param => value...])) |
114 | |
114 | |
115 | Checks the given token and returns true if the token has the minimum |
115 | Checks the given token and returns true if the token has the minimum |
116 | number of prefix bits, or false otherwise. The value returned is actually |
116 | number of prefix bits, or false otherwise. The value returned is actually |
117 | the number of collisions, so to find the number of collisions bits specify |
117 | the number of collisions, so to find the number of collisions bits specify |
118 | C<< collisions => 0 >>. |
118 | C<< collisions => 0 >>. |
119 | |
119 | |
120 | Any additional parameters are interpreted the same way as arguments to |
120 | Any additional parameters are interpreted the same way as arguments to |
121 | C<new>. |
121 | C<new>. |
122 | |
122 | |
123 | =item $resource = $cipher->resource($token) |
123 | =item $resource = $cipher->resource ($token) |
124 | |
124 | |
125 | Returns the resource part, or C<undef>. |
125 | Returns the resource part, or C<undef>. |
126 | |
126 | |
127 | =item $tstamp = $ciper->timestamp($token) |
127 | =item $tstamp = $ciper->timestamp ($token) |
128 | |
128 | |
129 | Returns the timestamp part (in the same format as perl's C<time>), or |
129 | Returns the timestamp part (in the same format as perl's C<time>), or |
130 | C<undef>. |
130 | C<undef>. |
131 | |
131 | |
132 | =back |
132 | =back |
… | |
… | |
186 | |
186 | |
187 | =head1 SEE ALSO |
187 | =head1 SEE ALSO |
188 | |
188 | |
189 | L<http://www.hashcash.org>. |
189 | L<http://www.hashcash.org>. |
190 | |
190 | |
|
|
191 | =head1 SUPPORT FOR THE PERL MULTICORE SPECIFICATION |
|
|
192 | |
|
|
193 | This module supports the perl multicore specification |
|
|
194 | (<http://perlmulticore.schmorp.de/>) for token generation of any length |
|
|
195 | and 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 | yeras 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 | |
204 | 1; |
210 | 1; |