line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Bytes::Random; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
70314
|
use 5.006000; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
34
|
|
5
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
36
|
|
6
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
35
|
|
7
|
1
|
|
|
1
|
|
1091
|
use bytes; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
4
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require Exporter; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT = qw( |
14
|
|
|
|
|
|
|
random_bytes |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
#============================================================================== |
21
|
|
|
|
|
|
|
sub random_bytes |
22
|
|
|
|
|
|
|
{ |
23
|
1000040
|
|
|
1000040
|
1
|
2569093
|
my $number = shift; |
24
|
1000040
|
50
|
|
|
|
1827505
|
return '' unless $number > 0; |
25
|
|
|
|
|
|
|
|
26
|
1000040
|
|
|
|
|
1151658
|
my @out = ( ); |
27
|
1000040
|
|
|
|
|
1460485
|
for( 1..$number ) |
28
|
|
|
|
|
|
|
{ |
29
|
1000820
|
|
|
|
|
1338685
|
my $rand = int( rand() * 256 ); |
30
|
1000820
|
|
|
|
|
2167813
|
push @out, chr( $rand ); |
31
|
|
|
|
|
|
|
}# end for() |
32
|
|
|
|
|
|
|
|
33
|
1000040
|
|
|
|
|
2881327
|
return join '', @out; |
34
|
|
|
|
|
|
|
}# end random_bytes() |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1;# return true: |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=pod |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 NAME |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Bytes::Random - Perl extension to generate random bytes. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 SYNOPSIS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
use Bytes::Random; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $bytes = random_bytes( $number_of_bytes ); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 DESCRIPTION |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
C provides the C function. It can be used |
53
|
|
|
|
|
|
|
anytime you need to generate a string of random bytes of a specific length. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 EXPORT |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head3 random_bytes( $number_of_bytes ) |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Returns a string containing as many random bytes as was requested. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 AUTHOR |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
John Drago, Ejdrago_999@yahoo.comE |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Copyright (C) 2009 John Drago - All Rights Reserved. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
71
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.10.0 or, |
72
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|