1 |
root |
1.1 |
NAME |
2 |
|
|
Digest::Hashcash - generate Hashcashes (http://www.hashcash.org) |
3 |
|
|
|
4 |
|
|
SYNOPSIS |
5 |
|
|
use Digest::Hashcash; |
6 |
|
|
|
7 |
|
|
DESCRIPTION |
8 |
|
|
This module implements the hashcash hash (or digest, although it's not |
9 |
|
|
clearly a digest). For all your information needs please visit |
10 |
|
|
http://www.hashcash.org. |
11 |
|
|
|
12 |
|
|
One thing to note about this module is that it requires ISO C99 support, |
13 |
|
|
both in your compiler and your standard library. If you don't have a |
14 |
|
|
compiler that supports ISO C, get gcc at http://gcc.gnu.org/ :) |
15 |
|
|
|
16 |
|
|
$cipher = new [param => value...] |
17 |
|
|
|
18 |
|
|
size => 20 + some |
19 |
|
|
The number of collisions, in bits. Every bit increases the time |
20 |
|
|
to create the token (and thus the cash) by two. |
21 |
|
|
|
22 |
|
|
uid => "" |
23 |
|
|
A string used to make the token more unique (e.g. the senders |
24 |
|
|
address) and reduce token collisions. The string must only |
25 |
|
|
contain characters valid for the trial part of the token, e.g. |
26 |
|
|
uuencoded, base64 or e-mail-address-parts are useful here. |
27 |
|
|
|
28 |
|
|
extrarand => 0 |
29 |
|
|
The extra bytes of randomness to add to the token in addition to |
30 |
|
|
the standard amount. Each byte adds a little bit over 6 bit of |
31 |
|
|
randomness to the token. |
32 |
|
|
|
33 |
|
|
The standard amount of randomness is 8 (> 51 bits of |
34 |
|
|
randomness). |
35 |
|
|
|
36 |
|
|
timestamp => 0 |
37 |
|
|
The timestamp to use. A value of 0 (the default) means to use |
38 |
|
|
the current time. |
39 |
|
|
|
40 |
|
|
$token = $cipher->hash($data [, param => value...]) |
41 |
|
|
Creates and returns a new token. This can take some time. |
42 |
|
|
|
43 |
|
|
Any additional parameters are interpreted the same way as arguments |
44 |
|
|
to "new". |
45 |
|
|
|
46 |
|
|
$prefix = $cipher->verify($token [, param => value...])) |
47 |
|
|
Checks the given token and returns true if the token has the minimum |
48 |
|
|
number of prefix bits, or false otherwise. The value returned is |
49 |
|
|
actually the number of collisions, so to find the number of |
50 |
|
|
collisions bits specify "collisions => 0". |
51 |
|
|
|
52 |
|
|
Any additional parameters are interpreted the same way as arguments |
53 |
|
|
to "new". |
54 |
|
|
|
55 |
|
|
$resource = $cipher->resource($token) |
56 |
|
|
Returns the resource part, or "undef". |
57 |
|
|
|
58 |
|
|
$tstamp = $ciper->timestamp($token) |
59 |
|
|
Returns the timestamp part (in the same format as perl's "time"), or |
60 |
|
|
"undef". |
61 |
|
|
|
62 |
|
|
SEE ALSO |
63 |
|
|
<http://www.hashcash.org>. |
64 |
|
|
|
65 |
|
|
BUGS |
66 |
|
|
* There is a y2k+100 problem, as I always assume the same as Time::Local. |
67 |
|
|
This is a problem with the hashcash specification, which specifies |
68 |
|
|
yeras as 2 digits :( |
69 |
|
|
|
70 |
|
|
AUTHOR |
71 |
|
|
Marc Lehmann <pcg@goof.com> |
72 |
|
|
http://home.schmorp.de |
73 |
|
|
|