1 |
=head1 NAME |
2 |
|
3 |
AnyEvent::MP::Util - utility cruft |
4 |
|
5 |
=head1 SYNOPSIS |
6 |
|
7 |
use AnyEvent::MP::Util; |
8 |
|
9 |
# undocumented |
10 |
|
11 |
=head1 DESCRIPTION |
12 |
|
13 |
Guess. |
14 |
|
15 |
=head1 FUNCTIONS/METHODS |
16 |
|
17 |
Guess. |
18 |
|
19 |
=over 4 |
20 |
|
21 |
=cut |
22 |
|
23 |
package AnyEvent::MP::Util; |
24 |
|
25 |
use common::sense; |
26 |
|
27 |
our $VERSION = '0.0'; |
28 |
|
29 |
# => util |
30 |
sub nonce($) { |
31 |
my $nonce; |
32 |
|
33 |
if (open my $fh, "</dev/urandom") { |
34 |
sysread $fh, $nonce, $_[0]; |
35 |
} else { |
36 |
# shit... |
37 |
our $nonce_init; |
38 |
unless ($nonce_init++) { |
39 |
srand time ^ $$ ^ unpack "%L*", qx"ps -edalf" . qx"ipconfig /all"; |
40 |
} |
41 |
|
42 |
$nonce = join "", map +(chr rand 256), 1 .. $_[0] |
43 |
} |
44 |
|
45 |
$nonce |
46 |
} |
47 |
|
48 |
=back |
49 |
|
50 |
=head1 SEE ALSO |
51 |
|
52 |
L<AnyEvent::MP>. |
53 |
|
54 |
=head1 AUTHOR |
55 |
|
56 |
Marc Lehmann <schmorp@schmorp.de> |
57 |
http://home.schmorp.de/ |
58 |
|
59 |
=cut |
60 |
|
61 |
1 |
62 |
|