… | |
… | |
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 |