… | |
… | |
11 | |
11 | |
12 | One thing to note about this module is that it requires ISO C99 support, |
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 |
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/ :) |
14 | compiler that supports ISO C, get gcc at http://gcc.gnu.org/ :) |
15 | |
15 | |
16 | $cipher = new [param => value...] |
16 | $secs = estimate_time $size |
|
|
17 | Estimate the average time necessary to calculate a token of the |
|
|
18 | given size. |
17 | |
19 | |
18 | size => 20 + some |
20 | See also "estimate_size". |
|
|
21 | |
|
|
22 | $size = estimate_size $time[, $min] |
|
|
23 | Estimate the size that can be calculated in the given time (which is |
|
|
24 | an upper bound). The function will not return a size less then |
|
|
25 | "min". |
|
|
26 | |
|
|
27 | Estimating the time to be used can go wrong by as much as 50% (but |
|
|
28 | is usually quite accurate), and the estimation itself can take as |
|
|
29 | much as a second on slower (<pentium) machines, but faster machines |
|
|
30 | (1Ghz P3 for example) usually handle it within a hundredth of a |
|
|
31 | second or so. |
|
|
32 | |
|
|
33 | The estimation will be done only once, so you can call this fucntion |
|
|
34 | as often as you like without incuring the overhead everytime. |
|
|
35 | |
|
|
36 | $cipher = new Digest::Hashcash [param => value...] |
|
|
37 | |
|
|
38 | size => 18 |
19 | The number of collisions, in bits. Every bit increases the time |
39 | The number of collisions, in bits. Every bit increases the time |
20 | to create the token (and thus the cash) by two. |
40 | to create the token (and thus the cash) by two. |
21 | |
41 | |
22 | uid => "" |
42 | uid => "" |
23 | A string used to make the token more unique (e.g. the senders |
43 | A string used to make the token more unique (e.g. the senders |
… | |
… | |
35 | |
55 | |
36 | timestamp => 0 |
56 | timestamp => 0 |
37 | The timestamp to use. A value of 0 (the default) means to use |
57 | The timestamp to use. A value of 0 (the default) means to use |
38 | the current time. |
58 | the current time. |
39 | |
59 | |
40 | $token = $cipher->hash($data [, param => value...]) |
60 | $token = $cipher->hash ($data [, param => value...]) |
41 | Creates and returns a new token. This can take some time. |
61 | Creates and returns a new token. This can take some time. |
42 | |
62 | |
43 | Any additional parameters are interpreted the same way as arguments |
63 | Any additional parameters are interpreted the same way as arguments |
44 | to "new". |
64 | to "new". |
45 | |
65 | |
46 | $prefix = $cipher->verify($token [, param => value...])) |
66 | $prefix = $cipher->verify ($token [, param => value...])) |
47 | Checks the given token and returns true if the token has the minimum |
67 | 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 |
68 | number of prefix bits, or false otherwise. The value returned is |
49 | actually the number of collisions, so to find the number of |
69 | actually the number of collisions, so to find the number of |
50 | collisions bits specify "collisions => 0". |
70 | collisions bits specify "collisions => 0". |
51 | |
71 | |
52 | Any additional parameters are interpreted the same way as arguments |
72 | Any additional parameters are interpreted the same way as arguments |
53 | to "new". |
73 | to "new". |
54 | |
74 | |
55 | $resource = $cipher->resource($token) |
75 | $resource = $cipher->resource ($token) |
56 | Returns the resource part, or "undef". |
76 | Returns the resource part, or "undef". |
57 | |
77 | |
58 | $tstamp = $ciper->timestamp($token) |
78 | $tstamp = $ciper->timestamp ($token) |
59 | Returns the timestamp part (in the same format as perl's "time"), or |
79 | Returns the timestamp part (in the same format as perl's "time"), or |
60 | "undef". |
80 | "undef". |
61 | |
81 | |
62 | SEE ALSO |
82 | SEE ALSO |
63 | <http://www.hashcash.org>. |
83 | <http://www.hashcash.org>. |
64 | |
84 | |
65 | BUGS |
85 | BUGS |
66 | * There is a y2k+100 problem, as I always assume the same as Time::Local. |
86 | * 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 |
87 | This is a problem with the hashcash specification, which specifies |
68 | yeras as 2 digits :( |
88 | years as 2 digits :( |
69 | |
89 | |
70 | AUTHOR |
90 | AUTHOR |
71 | Marc Lehmann <pcg@goof.com> |
91 | Marc Lehmann <schmorp@schmorp.de> |
72 | http://home.schmorp.de |
92 | http://home.schmorp.de |
73 | |
93 | |